Post

Replies

Boosts

Views

Activity

Reply to Initializing a @StateObject from an @EnvironmentObject
So what's the solution for using MVVM in a setup where you're using EnvironmentObject to pass in access to the model? I'm thinking of something like Core Data where you can use an EnvironmentObject to pass in an NSManagedObjectContext. You can't create an @EnvironmentObject ViewModel in init because the EnvironmentObject isn't set yet. And the EnvironmentObject property's didSet doesn't fire so you can't do it there. Creating the ViewModel in onAppear works but seems a bit clumsy. Is that the best way to do this?
Jul ’21
Reply to FileDocument, Transferable, and DocumentGroup
I'm not sure what to make of DocumentGroup. It seems like the way we're supposed to create a document-based SwiftUI app, but it's missing major pieces of functionality. For example, there's no way to do state restoration. No way to run tests that create and open documents. No clear way to present first-run UI or let the user pick a document type to create. Is everyone rolling their own alternative or how are people handling this?
Jul ’23