Recall & Review
beginner
What is the common way to pass data between view controllers in iOS using Swift?
You usually pass data by setting a property on the destination view controller before the transition happens, often inside the prepare(for:sender:) method.
Click to reveal answer
beginner
What method do you override to prepare data before a segue transition?
Override the prepare(for segue: UIStoryboardSegue, sender: Any?) method to access the destination view controller and pass data to it.
Click to reveal answer
intermediate
How do you safely get the destination view controller inside prepare(for:sender:)?
Use optional binding (if let) to cast segue.destination to the expected view controller type before setting its properties.
Click to reveal answer
intermediate
Why is it important to pass data before the segue transition completes?
Because the destination view controller's view loads after the segue, so setting data beforehand ensures it is ready when the new screen appears.
Click to reveal answer
advanced
Can you pass data back from the destination to the source view controller using prepare(for:sender:)?
No, prepare(for:sender:) is only for passing data forward. To pass data back, use delegation, closures, or unwind segues.
Click to reveal answer
Which method is used to pass data to the next view controller during a segue?
✗ Incorrect
prepare(for:sender:) is called before the segue transition and is the place to pass data to the destination view controller.
How do you access the destination view controller inside prepare(for:sender:)?
✗ Incorrect
segue.destination gives you the view controller you are navigating to, so you can set its properties.
What Swift feature helps safely cast the destination view controller to the correct type?
✗ Incorrect
Optional binding (if let) safely unwraps and casts the destination view controller to the expected type.
When should you pass data to the destination view controller?
✗ Incorrect
Passing data inside prepare(for:sender:) ensures the destination has the data before its view loads.
Which method is NOT used to pass data back from a destination view controller?
✗ Incorrect
prepare(for:sender:) is only for passing data forward, not back.
Explain how to pass data from one view controller to another using a segue in Swift.
Think about the method called before the screen changes.
You got /3 concepts.
Describe ways to send data back from a destination view controller to the source view controller.
Passing data back is different from passing data forward.
You got /4 concepts.