← iOS Development (Swift) learning path
iOS Development (Swift) · Module 6 of 10

State and data flow

Update UI with @State, @Binding and observable models.

📖 Key ideas

  1. @State stores local view state; changing it updates the UI.
  2. @Binding lets a child edit a parent's state.
  3. @Observable classes share model data (iOS 17+).
  4. @Environment reads shared values like colour scheme.
  5. Keep one source of truth.
💡 Real-life example: A @Binding is a shared remote: the child presses buttons, but the TV (state) belongs to the parent.
@StateLocal view state
@BindingTwo-way link to parent state
@ObservableMacro making a class observable
@EnvironmentReads shared environment values