A persistent value of a given type, through which a view reads and monitors the value.
- iOS 13.0+Beta
- macOS 10.15+Beta
- Mac Catalyst 13.0+Beta
- tvOS 13.0+Beta
- watchOS 6.0+Beta
- Xcode 11.0+Beta
SwiftUI manages the storage of any property you declare as a state. When the state value changes, the view invalidates its appearance and recomputes the
body. Use the state as the single source of truth for a given view.
State instance isn’t the value itself; it’s a means of reading and mutating the value. To access a state’s underlying value, use its
Only access a state property from inside the view’s
body (or from functions called by it). For this reason, you should declare your state properties as
private, to prevent clients of your view from accessing it.
You can get a binding from a state with the `binding` property, or by using the `$` prefix operator.