Which code snippet correctly implements this with minimal repetition?
hard📝 navigation Q15 of 15
iOS Swift - Navigation
You want to create a TabView with three tabs: Home, Search, and Profile. Each tab should show a different view and have a label with a system icon. Which code snippet correctly implements this with minimal repetition?
TabView {
HomeView().tabItem { Label("Home", systemImage: "house") }
SearchView().tabItem { Label("Search", systemImage: "magnifyingglass") }
ProfileView().tabItem { Label("Profile", systemImage: "person") }
} correctly uses braces with Label including both text and systemImage for each tab.
Step 2: Review other options for errors
TabView {
HomeView().tabItem(Label("Home", systemImage: "house"))
SearchView().tabItem(Label("Search", systemImage: "magnifyingglass"))
ProfileView().tabItem(Label("Profile", systemImage: "person"))
} misses braces, causing syntax errors. TabView {
HomeView().tabItem { Text("Home") }
SearchView().tabItem { Text("Search") }
ProfileView().tabItem { Text("Profile") }
} uses Text instead of Label, so no icons. TabView {
HomeView().tabItem { Label("Home") }
SearchView().tabItem { Label("Search") }
ProfileView().tabItem { Label("Profile") }
} uses Label without systemImage, so no icons.