← iOS Development (Swift) learning pathiOS Development (Swift) · Module 6 of 10
State and data flow
Update UI with @State, @Binding and observable models.
📖 Key ideas
- @State stores local view state; changing it updates the UI.
- @Binding lets a child edit a parent's state.
- @Observable classes share model data (iOS 17+).
- @Environment reads shared values like colour scheme.
- 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