From the course: Make SwiftUI Playgrounds Applications

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

More on the view hierarchy

More on the view hierarchy

- [Steven] We've begun to explore how models and views are put together. In the previous videos, I looked at the model more than the view. This time I want to look more at the view hierarchy. The pizzas on our menu have an id number. The id number, among other things, will identify images of the pizzas. We don't have the correct images yet, but we can set up that id number. So let's use the id to take a tour of the view hierarchy. A view hierarchy is the way we connect the views we've made in SwiftUI together. On top we have ContentView, which heads down to MenuItemView. MenuItemView either displays HMenuItemView or VMenuItemView. Currently we are passing a String in ContentView to MenuItemView to the H or VMenuItemViews. It's only one property of the pizza. I'd have to add a lot of parameters to pass more than this if I wanted, say, a name, a description, a price, and an id. By passing the entire MenuItem struct…

Contents