Future of CoreData? SwiftUI, structs, `Identifiable`

I think you're mixing two different things here. The "models" you refer to in a SwiftUI context are view models, not domain models. While it's tempting to reuse domain models as view models, keeping them separate will pay off in the long run.

For example, you may have a User class to represent a user, and a UserViewModel struct to represent the data you display on the user's profile screen. Even though these types are similar and share many properties, you should view them as entirely different things.

if you'd already adopted this separation of domain model vs. view models, switching from UIKit to SwiftUI shouldn't affect your persistence code at all, since you're persisting domain models, not view models.

That being said, it's safe to assume Apple wants to make the most of their pretty new language and may be working on (or at least thinking about) an updated persistence framework. But if and when that'll be released is for them to know and for us to find out about at WWDC :wink:

1 Like