Bird
0
0

Identify the error in this SwiftUI code snippet:

medium📝 Debug Q14 of 15
iOS Swift - Navigation
Identify the error in this SwiftUI code snippet:
NavigationLink(destination: Text("Details"))
Text("Tap here")
AMissing braces {} around the label view
BDestination cannot be a Text view
CNavigationLink must be inside a NavigationView
DText("Tap here") should be inside destination
Step-by-Step Solution
Solution:
  1. Step 1: Check NavigationLink syntax

    NavigationLink requires a closure with braces {} for the label view.
  2. Step 2: Analyze given code

    The label Text("Tap here") is outside NavigationLink without braces, causing syntax error.
  3. Final Answer:

    Missing braces {} around the label view -> Option A
  4. Quick Check:

    Label must be inside braces {} [OK]
Quick Trick: Label view must be inside braces {} after NavigationLink [OK]
Common Mistakes:
  • Omitting braces for label view
  • Thinking destination can't be Text
  • Assuming NavigationView is mandatory for syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes