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.

Observable objects

Observable objects

- [Instructor] One major change to Swift UI is an improvement over the observed object and environment object we've used in this course called observable. Let's change the app to use this and understand why you might want to, first of all, I'm going to close up the preview here, the command return. So we have plenty of room to work and I'm going to head over to order model to start this 'cause we're going to be looking at models, and you'll see here we've got an order model like here. And I'm going to comment out that line, and I'm going to replace it with an observable version of it. And that's at observable class order model and bracket in there. That is all we need to do to get this started. Observable is a macro, which sets up everything you need to use the observable protocol. Now this also will start a cascade of error message. So we can go over here to error and start looking at them. And as you see right now, they're not there yet. As a macro, error messages don't show up…

Contents