Toot

Written by Rhys Morgan on 2024-11-02 at 17:38

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 | View the thread | More toots from rhysmorgan@mastodon.social

Mentions

Tags

=> View iosdev tag | View swiftlang tag | View swiftui tag

Proxy Information
Original URL
gemini://mastogem.picasoft.net/toot/113414576582409082
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
225.350272 milliseconds
Gemini-to-HTML Time
1.007389 milliseconds

This content has been proxied by September (3851b).