Bird
0
0

You want to programmatically navigate to a ProfileViewController and pass a username string to it. Which approach correctly achieves this?

hard📝 navigation Q8 of 15
iOS Swift - Navigation
You want to programmatically navigate to a ProfileViewController and pass a username string to it. Which approach correctly achieves this?
ACreate ProfileViewController instance, set username property, then push it
BPush ProfileViewController and then set username property after navigation
CUse storyboard segue with identifier instead of pushViewController
DSet username property on current view controller before pushing
Step-by-Step Solution
Solution:
  1. Step 1: Instantiate and configure before navigation

    Create the destination view controller and set its properties before pushing it.
  2. Step 2: Push the configured view controller

    Push the configured instance to navigate and pass data correctly.
  3. Final Answer:

    Create ProfileViewController instance, set username property, then push it -> Option A
  4. Quick Check:

    Set properties before push to pass data [OK]
Quick Trick: Set data on VC before pushing it to pass info [OK]
Common Mistakes:
  • Setting properties after pushing VC
  • Trying to set data on current VC instead of destination
  • Confusing push with segue usage

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes