Bird
0
0

Which of the following is the correct way to start a NavigationStack in SwiftUI?

easy📝 Syntax Q3 of 15
iOS Swift - Navigation
Which of the following is the correct way to start a NavigationStack in SwiftUI?
ANavigationLink { Text("Home") }
BNavigationStack { Text("Home") }
CNavigationView { Text("Home") }
DNavigationStack(Text("Home"))
Step-by-Step Solution
Solution:
  1. Step 1: Recall NavigationStack syntax

    NavigationStack is a container view that takes a closure with child views inside curly braces.
  2. Step 2: Check each option

    NavigationLink { Text("Home") } incorrectly uses a link as a container; NavigationView { Text("Home") } uses deprecated NavigationView; NavigationStack(Text("Home")) is invalid syntax.
  3. Final Answer:

    NavigationStack { Text("Home") } -> Option B
  4. Quick Check:

    NavigationStack syntax = braces with content [OK]
Quick Trick: NavigationStack uses braces {} to wrap content [OK]
Common Mistakes:
  • Using NavigationView instead of NavigationStack
  • Passing views as parameters instead of closure
  • Confusing NavigationLink with NavigationStack

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes