0Pricing
Swift Academy · Lesson

@Binding: Two-Way Data Flow

Passing mutable state down the view hierarchy with @Binding and $ prefix.

Welcome

`@Binding` creates a two-way connection between a parent's state and a child view, allowing the child to read and write the parent's value without owning it.

Creating a Binding

```swift struct Parent: View { @State private var name = "" var body: some View { ChildView(name: $name) // $ creates Binding } } struct ChildView: View { @Binding var name: String var body: some View { TextField("Name", text: $name) } } ```

All lessons in this course

  1. @Binding: Two-Way Data Flow
  2. @ObservableObject and @StateObject
  3. @EnvironmentObject for Shared State
  4. Single Source of Truth and Unidirectional Flow
← Back to Swift Academy