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:
Step 1: Recall NavigationStack syntax
NavigationStack is a container view that takes a closure with child views inside curly braces.
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.
Final Answer:
NavigationStack { Text("Home") } -> Option B
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
Master "Navigation" in iOS Swift
9 interactive learning modes - each teaches the same concept differently