From the course: Complete Guide to SwiftUI

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

Deeper navigation stacks

Deeper navigation stacks

- [Instructor] You've seen a simple case of a navigation stack to a single view, which is something you can do with a sheet. Where navigation stacks come to their own is with more than one view in navigation. I'm going to add one more feature to the menu item view, a random suggestion for another pizza. This will simulate one of those "You Might Like" views you find in many shopping apps. So let's go to menu item view to start this, and I can get rid of the preview for the moment So we have plenty of room to work. and I'm going to add at the top, a declaration, state private var. We'll put a suggested item in here, and that's going to be a menu item. And we're going to assign that from a menu model, and that'll be a menu. And we're going to use a random element that needs to be unwrapped. So I'm going to go ahead and do this. No menu item. And that gives us a random item to play with. Now we're going to go to the button here, okay? And right above the button where we present the view,…

Contents