Finally, we have what you can think of as the back-end layer: processing that happens - probably in the background - to populate your model or talk to the world outside your app. It might just be a projection of your data model or a subset of it just what you need to display on the UI at this moment. I'm referring to it as a UI model because it might not be the full model of all of your application's data. It's an observable object that feeds our SwiftUI view, and all of the updates on it will need to be made on the main thread. That is, the place where you hold data for display by the UI layer. Next there's the model layer that comprises a couple of simple value types to represent caffeine drinks, as well as a model type called "Coffee model." Now, this is what you might call the UI Model. This is mostly SwiftUI views, but in this we can also consider things like the complication data source as part of the UI layer. It's roughly broken up into three layers. It's a nice example to use for our purposes because although it's a small app, it shows lots of different things we want to think about, including how concurrency works with SwiftUI, delegate callbacks from the watch SDK, some I/O, and interfacing with asynchronous APIs in Apple's SDK. This is a simple app that lets you track all the coffee you've drunk today, as well as a complication to show your current caffeine level on a watch face. I'm going to be using an app called Coffee Tracker, and it's based on a talk from WWDC 2020 about creating and updating watch complications. We'll see how these new features help you write clearer asynchronous code, and protect against possible race conditions, as well as look at some techniques for gradually moving your code to this new way of operating. ♪ Bass music playing ♪ ♪ Ben Cohen: Hi, I'm Ben from the Swift team, and in this video, I'm going to walk through porting an existing application over to use Swift's new concurrency features.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |