A property wrapper type that can read and write a value owned by a source of truth.
- iOS 13.0+
- macOS 10.15+
- Mac Catalyst 13.0+
- tvOS 13.0+
- watchOS 6.0+
- Xcode 11.0+
Use a binding to create a two-way connection between a property that stores data, and a view that displays and changes the data. A binding connects a property to a source of truth stored elsewhere, instead of storing data directly. For example, a button that toggles between play and pause can create a binding to a property of its parent view using the
@Binding property wrapper.
The parent view declares a property to hold the playing state, using the
@State property wrapper to indicate that this property is the value’s source of truth.
Play, it passes a binding of its state property into the button’s binding property. Applying the
$ prefix to a property wrapped value returns its
projected, which for a state property wrapper returns a binding to the value.
Whenever the user taps the
Player updates its