Bird
0
0

Which of the following is the correct way to create a NavigationLink with a label "Continue" that navigates to a Text view displaying "Next Screen"?

easy📝 Syntax Q3 of 15
iOS Swift - Navigation
Which of the following is the correct way to create a NavigationLink with a label "Continue" that navigates to a Text view displaying "Next Screen"?
ANavigationLink(Text("Continue"), destination: Text("Next Screen"))
BNavigationLink(destination: Text("Next Screen")) { Text("Continue") }
CNavigationLink(label: Text("Continue"), destination: Text("Next Screen"))
DNavigationLink(destination: Text("Continue")) { Text("Next Screen") }
Step-by-Step Solution
Solution:
  1. Step 1: Understand NavigationLink syntax

    The correct initializer uses destination as the first parameter and a trailing closure for the label.
  2. Step 2: Match label and destination

    The label should be "Continue" and the destination should be Text("Next Screen").
  3. Final Answer:

    NavigationLink(destination: Text("Next Screen")) { Text("Continue") } -> Option B
  4. Quick Check:

    Trailing closure syntax with destination first [OK]
Quick Trick: Destination first, label in trailing closure [OK]
Common Mistakes:
  • Swapping label and destination parameters
  • Using incorrect initializer syntax
  • Placing label inside destination

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes