Recall & Review
beginner
What is the purpose of
@Binding in SwiftUI?@Binding allows a child view to read and write a value owned by a parent view. It creates a two-way connection so changes in the child update the parent.
Click to reveal answer
beginner
How do you declare a
@Binding property in a child view?Use @Binding var propertyName: Type inside the child view struct to declare a binding property.
Click to reveal answer
beginner
How does a parent pass a binding to a child view?
The parent passes a binding by prefixing the state variable with a $ sign, like ChildView(propertyName: $parentState).
Click to reveal answer
intermediate
What happens if a child view modifies a
@Binding property?Modifying a @Binding property updates the original source of truth in the parent view, causing the UI to refresh accordingly.
Click to reveal answer
intermediate
Why is
@Binding preferred over passing values directly for child communication?@Binding keeps data in sync between parent and child without duplicating state, avoiding bugs and making UI reactive.
Click to reveal answer
What symbol do you use to pass a binding from a parent to a child view?
✗ Incorrect
In SwiftUI, the
$ prefix is used to pass a binding to a child view.Which property wrapper allows a child view to modify a parent's state?
✗ Incorrect
@Binding creates a two-way connection so the child can modify the parent's state.If a child view changes a
@Binding property, what happens?✗ Incorrect
Changing a
@Binding property updates the parent's source of truth and refreshes the UI.Which of these is NOT true about
@Binding?✗ Incorrect
@Binding does NOT duplicate state; it references the parent's state directly.Where do you declare the
@Binding property in SwiftUI?✗ Incorrect
@Binding is declared in the child view to receive a reference to the parent's state.Explain how
@Binding enables communication between a parent and child view in SwiftUI.Think about how changes in the child affect the parent.
You got /4 concepts.
Describe the steps to pass a state variable from a parent view to a child view using
@Binding.Focus on property wrappers and passing syntax.
You got /4 concepts.