flâneur — a map of the web's best reading

tag(_:includeOptional:) | Apple Developer Documentation

developer.apple.com · 185 words · saved by 1 readers

Use this modifier to differentiate among certain selectable views, like the possible values of a Picker or the tabs of a TabView. Tag values can be of any type that conforms to the Hashable protocol. This modifier will write the tag value for the type V, as well as Optional if includeOptional is enabled. Containers checking for tags of either type will see the value as set. In the example below, the ForEach loop in the Picker view builder iterates over the Flavor enumeration. It extracts the string value of each enumeration element for use in constructing the row label, and uses the enumeration value as input to the tag(_:) modifier. The selection type of the Picker is an Optional and so it will look for tags on its contents of Optional type. Since the tag modifier defaults to having includeOptional enabled, even though the tag for each option is a non-optional Flavor, the tag modifier writes values for both the non-optional, and optional versions of the value, allowi

To navigate the symbols, press Up Arrow, Down Arrow, Left Arrow or Right Arrow No items were found 1 item was found {number} items were found. Tab back to navigate through them. re looking for can't be found."},"color-scheme":{"select":"Select a color scheme preference","auto":"Auto","dark":"Dark","light":"Light"},"accessibility":{"strike":{"start":"start of stricken text","end":"end of stricken text"},"code":{"start":"start of code block","end":"end of code block"},"skip-navigation":"Skip Navigation","in-page-link":"in page link"},"select-language":"Select the language for this page","icons":

Explore this link on the map →

related reading