Inside SceneDelegate
the context is passed via .environment(\.managedObjectContext, context)
why cannot it be passed via View's property? What's the advantage of doing so?
So instead of doing below
let contentView = FlightsEnrouteView()
.environment(\.managedObjectContext, context)
We can pass the context via the View's initializer
let contentView = FlightsEnrouteView(context: context)
so inside FlightsEnrouteView
should be,
struct FlightsEnrouteView: View {
var context: NSManagedObjectContext
}
Test it and it compiles