From the course: iPadOS 13 Development Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Creating a SwiftUI navigation model

Creating a SwiftUI navigation model - iOS Tutorial

From the course: iPadOS 13 Development Essential Training

Start my 1-month free trial

Creating a SwiftUI navigation model

- [Instructor] Now let's look at adding a data model to our View. So we have our NavigationView, we have a list of items. Let's say that list comes from an array, because without that list isn't as useful. So what we're going to need to do first, is create a data model. So we'll call this struct item, and it's going to inherit from identifiable, which just means it has a property called id. And this has to be unique. And then we'll create a variable called description, that will be a string. And then in our DetailView, let's receive that item. So we create a property called item. And then in the text, we'll have item.description. Now we have an error right here. Don't worry about that for now. We're going to address to it, momentarily. Now we need to create our data model, which will be an array of item objects. So create a variable called items. And this is going to be an array of items. And we'll set it equal…

Contents