From the course: Complete Guide to SwiftUI
Unlock this course with a free trial
Join today to access over 24,600 courses taught by industry experts.
Add a model to root views
From the course: Complete Guide to SwiftUI
Add a model to root views
- [Instructor] We don't have a real menu yet. For that, we need a model of menu items. It's time we load that into our app and see a model work. We've loaded the menu model in an earlier video in the model code group. And you'll see in there if you take a look that it's really made up of two files. It's the menu model, and it's the menu item. The menu item hasn't yet adapted identifiable, but it does have an ID, so it's not a bad idea to put it in there like so. And now I have that protocol because I have this in place. We're all set to go as far as using it for whatever I need. And then if I look a little further down here, I've got two enumerations that I'm using in my menu model right here, the item for the pizza crust and the menu category, which we'll get to as we go through the rest of the course. The menu model itself is just a collection of these, and it's just essentially a big array. Now I take that array from a JSON file, which instead of making it external files for this…
Contents
-
-
-
-
-
-
(Locked)
MVC vs. MVVM4m 19s
-
(Locked)
State variables and buttons3m 57s
-
(Locked)
Challenge: Add a button45s
-
(Locked)
Solution: Add a button3m 50s
-
(Locked)
Use Binding variables10m 10s
-
(Locked)
The Identifiable protocol5m 13s
-
(Locked)
Add a model to root views6m 47s
-
Populating collections with List4m 45s
-
(Locked)
Selection and binding variables6m 29s
-
(Locked)
-
-
-
-
-
-
-
-
-
-
-
-