projectedValue
A projection of the state object that creates bindings to its properties.
Declaration
@MainActor @preconcurrency var projectedValue: ObservedObject<ObjectType>.Wrapper { get }Discussion
Use the projected value to get a Binding to a property of a state object. To access the projected value, prefix the property name with a dollar sign ($). For example, you can get a binding to a model’s isEnabled Boolean so that a Toggle can control the value:
struct MyView: View {
@StateObject private var model = DataModel()
var body: some View {
Toggle("Enabled", isOn: $model.isEnabled)
}
}