projectedValue
A projection of the observed 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 an observed object. To access the projected value, prefix the property variable with a dollar sign ($). For example, you can get a binding to a model’s isEnabled Boolean so that a Toggle can control its value:
struct MySubView: View {
@ObservedObject var model: DataModel
var body: some View {
Toggle("Enabled", isOn: $model.isEnabled)
}
}