Reputation: 1481
I have a issue with use CoreData + iCloud sync.
Sometimes, the notification, NSPersistentStoreDidImportUbiquitousContentChangesNotification, returns a empty array in Inserted, Updated and Deleted.
If this notification is called when have changes, why return a empty notification?
Thanks!!!
Code that calls the Notification:
- (void)persistentStoreDidChange:(NSNotification*)notification
{
DLog(@"Change Detected! Notification: %@", notification.description)
[__managedObjectContext performBlockAndWait:^(void)
{
[__managedObjectContext mergeChangesFromContextDidSaveNotification:notification];
for(id<CoreDataDelegate>delegate in _delegates)
{
if([delegate respondsToSelector:@selector(persistentStoreDidChange)])
[delegate persistentStoreDidChange];
}
}];
}
Upvotes: 2
Views: 644
Reputation: 70936
It just does that sometimes. It's a pretty minor issue compared to the many severe problems of iCloud with Core Data.
What I like to do when receiving this notification is to check for inserted, updated, and deleted objects first, and then don't go ahead with the merge process unless you find something. Do something like
NSDictionary *userInfo = [notification userInfo];
if (([userInfo objectForKey:NSInsertedObjectsKey] > 0) ||
([userInfo objectForKey:NSUpdatedObjectsKey] > 0) ||
([userInfo objectForKey:NSDeletedObjectsKey] > 0))
{
// merge...
}
Upvotes: 3