0
0
iOS Swiftmobile~5 mins

@Binding for child communication in iOS Swift - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
A$
B&
C*
D#
Which property wrapper allows a child view to modify a parent's state?
A@State
B@ObservedObject
C@Binding
D@EnvironmentObject
If a child view changes a @Binding property, what happens?
AOnly the child view updates
BThe parent view's state updates
CNothing changes
DThe app crashes
Which of these is NOT true about @Binding?
AIt duplicates the state in the child
BIt requires a parent to own the state
CIt keeps data in sync
DIt allows two-way data flow
Where do you declare the @Binding property in SwiftUI?
AIn the parent view
BIn the SceneDelegate
CIn the AppDelegate
DIn the child view
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.