@Binding

Asked on 01/20/2025

1 search

In the context of SwiftUI, @Binding is a property wrapper that creates a two-way reference to the state of another view. This allows a view to read and write a value that is owned by a different view, enabling synchronization between views. For example, if you have a container view that manages a piece of state, you can pass a binding to a child view, allowing the child view to update the state and reflect those changes in the container view.

In the session "SwiftUI essentials," it is explained how a binding can be used to synchronize state between a container view and its child views, ensuring that they update in sync. This is particularly useful when you want multiple views to reflect the same piece of data without each maintaining its own separate state.

For more details, you can refer to the session SwiftUI essentials (12:29).