You are correct, but I believe there is more to the story. That solves the error that was initially raised, but doesn't actually adequately refresh the Master view with an update FetchRequest. Upon inserting the change to Detail view you suggested, the error no longer occurs. When trying to delete an item from the list though, the view still shows the item. It doesn't throw an error, but the item is not removed from the list. Again below are the only changes I have made to the sample project.struct ContentView: View {
@Environment(\.managedObjectContext)
var viewContext
var body: some View {
TabView {
NavigationView {
MasterView()
.navigationBarTitle(Text("Master"))
.navigationBarItems(
leading: EditButton(),
trailing: Button(
action: {
withAnimation { Event.create(in: self.viewContext) }
}
) {
Image(systemName: "plus")
}
)
Text("Detail view content goes here")
.navigationBarTitle(Text("Detail"))
}
.navigationViewStyle(DoubleColumnNavigationViewStyle())
.tabItem{ Text("Main") }
Text("Other Tab")
.tabItem{ Text("Other Tab") }
}
.onAppear {
print(self.viewContext)
}
}
}struct DetailView: View {
@ObservedObject var event: Event
var body: some View {
Text("\(event.timestamp ?? .distantPast, formatter: dateFormatter)")
.navigationBarTitle(Text("Detail"))
}
}For clarification, when first navigating to the Main tab, the view works as expected: items, when deleted, are promptly removed form the list with the standard animation and the view is refreshed. After navigating to another tab, and then navigating back to the Main tab, this is not the case. After returning to the main tab, deleting an item from the list does not actually delete it from the list in the view. The deletion is successful from core data (evident by the fact that switching again to the other tab and back again causes the item to no appear), but the view is not immediately refreshed, which is the expected and previosly observed effect.