Contents

init(_:)

Creates a bindable object from an observable object.

Declaration

init(_ wrappedValue: Value)

Discussion

This initializer is equivalent to init(wrappedValue:), but is more succinct when when creating bindable objects nested within other expressions. For example, you can use the initializer to create a bindable object inline with code that declares a view that takes a binding as a parameter:

struct TitleEditView: View {
    @Environment(Book.self) private var book

    var body: some View {
        TextField("Title", text: Bindable(book).title)
    }
}

See Also

Creating a bindable value