From the course: SwiftData Essential Training
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Solution: The names model - Swift Tutorial
From the course: SwiftData Essential Training
Solution: The names model
- [Instructor] So here's my solution, which I'll walk you through all the steps of how I did this. But first we're going to of course stop the app. And I'm going to go over here. And we have, in the models here, we've got name model, already defined. So we have our name model. I'm going to put in here SwiftData. So... So I'll quickly add SwiftData. And then I'll add the model, which looks all fine and good. Now I'm going to go ahead and I'm going to build this, because it doesn't do anything yet, until you build it. The thing about macros are they don't happen until they're built. So I'm going to do a command B here, and build this. And you'll get lots of errors. This is due to one of the most important things you must remember about models. They must be classes. So you'll see here it's a struct, and I don't want a struct, I want a class. And so I'll change that to a class. Build again. And all those error messages disappear really quickly. Okay, next we're going to register the model…