Which method is commonly overridden to pass data to the destination view controller before a segue?
easy📝 Syntax Q12 of 15
iOS Swift - Navigation
Which method is commonly overridden to pass data to the destination view controller before a segue?
Aprepare(for:sender:)
BapplicationDidBecomeActive()
CviewWillAppear()
DviewDidLoad()
Step-by-Step Solution
Solution:
Step 1: Identify the method for segue preparation
The method prepare(for:sender:) is called before a segue happens and is used to set data on the destination controller.
Step 2: Confirm other methods are unrelated
viewDidLoad() and viewWillAppear() are lifecycle methods but not used for passing data during segue. applicationDidBecomeActive() is an app lifecycle method.
Final Answer:
prepare(for:sender:) -> Option A
Quick Check:
Data passing before segue = prepare(for:sender:) [OK]
Quick Trick:Use prepare(for:sender:) to pass data before segue [OK]
Common Mistakes:
Using viewDidLoad() to pass data
Confusing lifecycle methods with segue methods
Trying to pass data after segue completes
Master "Navigation" in iOS Swift
9 interactive learning modes - each teaches the same concept differently