Hi
I wanted to move some code, that reads from a Core Data table in a SwiftUI View struct, from the body to the init. The NSManagedObjectContext is getting passed around in an environment declaration:
@Environment(\.managedObjectContext) private var viewContext: NSManagedObjectContext
But that doesn't work: the environment variables are not available in the init. There doesn't seem to be a good reason for that. Is there a way to read an environment variable in the init?
I know I could add another parameter to the init, but there are enough already, and that seems like poor style.