Playin\' with SwiftUI and Core Data brought me into a curious problem. So the situation is the following:
I have a main view \"AppView\" and a sub view named \"SubVi
WOW THIS DROVE ME NUTS! Especially because the errors tells you absolutely no information as to how to fix.
Here is the fix until the bug in Xcode is resolved:
.navigationBarItems(trailing:
Button(action: {
self.add = true
}, label: {
Text("Add Todo List")
}).sheet(isPresented: $add, content: {
AddTodoListView().environment(\.managedObjectContext, managedObjectContext)
})
)
Just add .environment(\.managedObjectContext, managedObjectContext)
to your secondary view (a Modal, in this example).