State

@propertyWrapper
public class State<Value>

Represents a mutable value to be held by a View. Reading a state’s wrappedValue property inside a view’s body computed property will trigger a subscribption by the view to listen to changes in the state’s value.

Important

You shouldn’t modify a state’s wrapped value when the view’s body property is being read.
  • Declaration

    Swift

    public init(wrappedValue value: Value)
  • The internal value of this wrapper type.

    Declaration

    Swift

    public var wrappedValue: Value { get set }
  • The direct value of this wrapper, as accessing $foo on a @State property.

    Declaration

    Swift

    public var projectedValue: Binding<Value> { get }