This is my app's processContentChanges: method, which is triggered by NSPersistentStoreDidImportUbiquitousContentChangesNotification
:
- (void)processContentChanges:(NSNotification *)notification {
[self.managedObjectContext performBlock:^{
// Merge incoming data updates in the managed object context
[self.managedObjectContext mergeChangesFromContextDidSaveNotification:notification];
// Post notification to trigger UI updates
#warning What do I actually do here?
}];
}
I'm using NSFetchedResultsController
s throughout my app so that the UI updates automatically when changes are received from another device through iCloud. This all seems to work, but the comment saying // Post notification to trigger UI updates
was there in the template method already. Am I actually supposed to do something here, or can I safely leave things the way they are?
Well, although I haven't had confirmation of this I don't think there is anything else that needs to be done in this method as long as the following criteria are met:
NSPersistentStoreDidImportUbiquitousContentChangesNotification
correctly as per the template so that new content is merged to the managed object contextNSFetchedResultsController
objectsNSFetchedResultsControllerDelegate
protocol, and implements controllerWillChangeContent:
, controllerDidChangeContent:
and controller:didChangeObject:atIndexPath:forChangeType:newIndexPath
If you have any objects which utilise CoreData without an NSFetchedResultsController
then you might need to update these by manually re-fetching the data when NSPersistentStoreDidImportUbiquitousContentChangesNotification
is posted by CoreData.