omg, just discovered a new API that seems to have been added (and backported!) in SwiftUI for setting the tag of a view for situations like a tabItem or Picker when the Binding type is Optional, and you're ForEach-ing over non-Optional values.
Instead of having to remember the magick invocation of:
Text(flavour.rawValue).tag(Optional.some(flavour))
you can now just use:
Text(flavour.rawValue).tag(flavour)
https://developer.apple.com/documentation/swiftui/view/tag(_:includeoptional:)/
[#]iosdev #swiftlang #swiftui
=> More informations about this toot | More toots from rhysmorgan@mastodon.social
This change seems to have happened without anyone calling it out? It's a massive improvement to SwiftUI, because the problem was pretty much impenetrable. You just had to know that your tag type needed to match – including optionality, which goes against most other cases in Swift. Now, you get correct behaviour by default!
[#]iosdev #swiftlang #swiftui
=> More informations about this toot | More toots from rhysmorgan@mastodon.social This content has been proxied by September (3851b).Proxy Information
text/gemini