I am writing a SwiftUI App using CoreData + CloudKit, based partly on sample code from `CoreDataCloudKitDemo`.
There is a MasterListView which presents a List of NavigationLinks of the available data, eg. Recents, Tags, etc. embedded in a Double Column Style NavigationView.
There are 6 @FetchRequest vars that collect the content for the different Sections in the List.
They look similar to this:
@FetchRequest(fetchRequest: ThingViewModel.fetchRequest(matching: .recent)) var recentThings:FetchedResults<Thing>
Where the .fetchRequest(matching: .recent) is producing a FetchRequest with Predicate and SortDescriptors.
The problems start when I use this in MultiTasking mode on an iPad. The user adds new data to the App using a Share Extension.
If I have the App side by side with another App that can share to it, the share is successful, I can see the data go into CoreData and the MasterListView re-draws by the logs but the actual data is not reliably refreshed.
I have logging in the MasterListView to tell me when it re-draws and when it receives a Notification from the core data stack that there has been an update.
The core data stack is running a NSPersistentHistoryChangeRequest, filtering out the added Thing successfully, so I know it is there.
I have tried everything I can think of, including things like:
NSManagedObjectContext.mergeChanges(fromRemoteContextSave:into:)
viewContext.stalenessInterval = 0
viewContext.refreshAllObjects()
viewContext.stalenessInterval = -1
And everything else I have found on SO ;-)
What am I missing?