OdyseeTeam / odysee-ios

The Odysee iOS app with wallet functionality.
MIT License
67 stars 22 forks source link

Use URL object in share sheet item #345

Closed ktprograms closed 1 year ago

ktprograms commented 1 year ago

Allows using URL-specific share sheet actions.

Fix: #325

anohren commented 1 year ago

It might read better to shorten the six lines for items into one through nil coalescing

ktprograms commented 1 year ago

@anohren I can't see how that's possible, since it'd be of different types.

anohren commented 1 year ago

As long as the type annotation is [Any] the types should all be inferred as Any. Does that not work?

let items: [Any] = [ URL(string: url) ?? url ]
ktprograms commented 1 year ago

Diff e6f0a45...6c30d67: Use nil coalescing for creating share item Thanks @anohren

ktprograms commented 1 year ago

On Fri Jul 8, 2022 at 9:51 AM +08, anohren wrote:

As long as the type annotation is [Any] the types should all be inferred as Any. Does that not work?

let items: [Any] = [ URL(string: url) ?? url ]

Ah, Thanks! Didn't know it worked like that.

-- Reply to this email directly or view it on GitHub: https://github.com/OdyseeTeam/odysee-ios/pull/345#issuecomment-1178448652 You are receiving this because you authored the thread.

Message ID: @.***>

anohren commented 1 year ago

No problem!

You can think of it as equivalent to e.g:

let s: String? = "a non-optional string"
let e: MyProtocol = MyConformer()

where the compiler knows to wrap your string in Optional.some, and to turn your value into the existential any MyProtocol only from reading your type annotations.