I spent my morning grappling emotionally with what Apple was telling me to do. The afternoon was, “OK, fine, we’ll try it your way.” The result was… pasta. Yes, pasta is definitely the analogy that I’m thinking of. Now, in the evening, I’ve come full circle and I’m going to do it exactly the way I wanted to in the first place. Whew - huge relief. But still wondering… (voiceStyle: .ultracalm) why are they saying to put data operations in the View?
Thanks for this example. I'm trying - and failing - to extend it to work with multiple models and datasources. For instance, Users accessible from a UserDataSource and UserGroups accessible from a UserGroupDataSource. Help appreciated.
I spent my morning grappling emotionally with what Apple was telling me to do. The afternoon was, “OK, fine, we’ll try it your way.” The result was… pasta. Yes, pasta is definitely the analogy that I’m thinking of. Now, in the evening, I’ve come full circle and I’m going to do it exactly the way I wanted to in the first place. Whew - huge relief. But still wondering… (voiceStyle: .ultracalm) why are they saying to put data operations in the View?
Haha because nobody at Apple has built a large complex SwiftUI app
Thanks for this example. I'm trying - and failing - to extend it to work with multiple models and datasources. For instance, Users accessible from a UserDataSource and UserGroups accessible from a UserGroupDataSource. Help appreciated.
I ran into the same problem and found this post https://developer.apple.com/forums/thread/759634
I've updated the initializer to take a ModelContainer and add all needed Models to it.
```Swift
init(container: ModelContainer) {
self.container = container
}
```
```Swift
let schema = Schema([Model1.self, Model2.self])
let modelConfiguration = ModelConfiguration(schema: schema)
let container = try ModelContainer(for: Model1.self, Model2.self, configurations: modelConfiguration)
self.model1DB = Model1Database(container: container)
self.model2DB = Model2Database(container: container)
```