FocusedValueKey
protocol · iOS 14.0+ · SDK 27.1
protocol FocusedValueKeyA protocol for identifier types used when publishing and observing focused values. Unlike ``EnvironmentKey``, `FocusedValueKey` has no default value requirement, because the default value for a key is always `nil`. Use the ``Entry`` macro to create custom focused values by extending `FocusedValues` with new properties: extension FocusedValues { @Entry var selectedItem: Item? } Alternatively it is possible to create a focused value key by manually creating a type that conforms to this protocol: struct SelectedItemKey: FocusedValueKey { typealias Value = Item } Then extend ``FocusedValues`` to add a computed property for your key: extension FocusedValues { var selectedItem: Item? { get { self[SelectedItemKey.self] } set { self[SelectedItemKey.self] = newValue } } }
Members (0)
This type has no directly callable members in this snapshot. See the framework’s skipped declarations for unsupported APIs.
Skipped declarations
No declarations were skipped in this snapshot.