Bird
0
0

Given this SwiftUI code inside a NavigationStack:

medium📝 Predict Output Q4 of 15
iOS Swift - Navigation
Given this SwiftUI code inside a NavigationStack:
NavigationLink("Go", destination: Text("Detail"))
What happens when the user taps "Go"?
ANothing happens because destination is missing
BThe app navigates to a screen showing "Detail" text
CThe app crashes due to syntax error
DThe app shows an alert instead of navigation
Step-by-Step Solution
Solution:
  1. Step 1: Understand NavigationLink behavior

    NavigationLink with a destination pushes the destination view when tapped.
  2. Step 2: Analyze the given code

    The destination is Text("Detail"), so tapping "Go" navigates to that screen.
  3. Final Answer:

    The app navigates to a screen showing "Detail" text -> Option B
  4. Quick Check:

    NavigationLink tap = navigate to destination [OK]
Quick Trick: NavigationLink tap pushes destination view [OK]
Common Mistakes:
  • Thinking destination is optional
  • Expecting alert instead of navigation
  • Assuming syntax error without checking code

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes