I use standard approach for injection of CoreData ManagedObjectContect from App struct
WindowGroup {
ContentView()
.environment(\.managedObjectContext, persistenceController.container.viewContext)
}
to all my views via wrapper
@Environment(\.managedObjectContext) private var viewContext
and it works fine. I'd like to create class with methods handling CoreData objects in the same context but @Environment wrapper used as above doesn't work in non SfiftUI file. What is recommended approach here to handle CoreData?