Recall & Review
beginner
What is "state" in the context of a mobile app UI?
State is the current data or information that the app uses to decide what to show on the screen. It can be user input, app settings, or any changing value.
Click to reveal answer
beginner
Why does changing state cause the UI to update automatically in reactive programming?
Because the UI listens to the state. When state changes, the UI reacts by re-drawing itself to match the new state, keeping the screen in sync with data.
Click to reveal answer
beginner
In SwiftUI, which property wrapper is used to mark a variable as state?
The @State property wrapper is used to mark a variable as state that can change and trigger UI updates.
Click to reveal answer
intermediate
How does separating UI from state help in app development?
It makes the app easier to understand and maintain because the UI just shows what the state says, and the state controls the data. This reduces bugs and makes updates simpler.
Click to reveal answer
intermediate
What happens if you update the UI directly without changing the state in a reactive framework?
The UI might show the change temporarily, but it can get out of sync because the state didn’t change. When the state updates later, the UI will reset to match the state, losing the direct change.
Click to reveal answer
What triggers a UI update in a reactive mobile app?
✗ Incorrect
In reactive apps, the UI updates automatically when the app's state changes.
Which SwiftUI property wrapper is used to create reactive state variables?
✗ Incorrect
@State marks variables that hold state and trigger UI updates when changed.
Why is it better to update state instead of UI directly in reactive frameworks?
✗ Incorrect
Updating state ensures the UI stays consistent and updates correctly.
What does the UI do when the state changes?
✗ Incorrect
The UI reacts by updating itself to reflect the new state.
Which of these best describes 'state' in a mobile app?
✗ Incorrect
State means the current data or information the app uses to show the UI.
Explain in your own words why state is important for reactive UI updates.
Think about how changing data should change what you see on screen.
You got /4 concepts.
Describe how you would use @State in SwiftUI to make a button update a label text.
Remember the state variable is the single source of truth for the label.
You got /4 concepts.