Note that there are some explanatory texts on larger screens.

plurals
  1. PONever getting iCloud change notifications
    primarykey
    data
    text
    <p>I am working on Core Data syncing over iCloud between two Mac applications. I have it mostly working (based on <a href="http://timroadley.com/2012/04/03/core-data-in-icloud/" rel="nofollow noreferrer">http://timroadley.com/2012/04/03/core-data-in-icloud/</a>) - data is being synced, but I'm never getting the content change notification I need to merge the changes into my local context.</p> <p>In my AppDelegate's managedObjectContext method:</p> <pre><code>NSManagedObjectContext * moc = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType]; [moc performBlockAndWait: ^{ [moc setPersistentStoreCoordinator:coordinator]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mergeChangesFrom_iCloud:) name:NSPersistentStoreDidImportUbiquitousContentChangesNotification object:coordinator]; }]; </code></pre> <p>My observer function never gets called:</p> <pre><code>- (void) mergeChangesFrom_iCloud:(NSNotification*) notification { NSLog(@"Merging changes from iCloud"); // everything past here is irrelevent - this log message never appears </code></pre> <p>The data store is most certainly being synced - deleting a record in app A and forcing a table reload in app B results in a Core Data fault failure as expected for unmerged changes. Quitting and restarting app B shows the correctly updated data.</p> <p>A breakpoint on the addObserver call shows it is being called. A breakpoint in <code>mergeChangesFrom_iCloud</code> shows that it is not.</p> <p>Why is the coordinator apparently never sending the <code>NSPersistentStoreDidImportUbiquitousContentChangesNotification</code> as the documentation (and tutorials) claim it should? Where can I begin debugging this?</p> <p><strong>Update</strong></p> <p>The mystery deepens. Using the Core Foundation function shown here - <a href="https://stackoverflow.com/questions/3725234/nsnotificationcenter-trapping-and-tracing-all-nsnotifications">NSNotificationCenter trapping and tracing all NSNotifications</a> - I do not see <code>NSPersistentStoreDidImportUbiquitousContentChangesNotification</code> appear at all among the mass of notifications flying by.</p> <p>It looks like it's not being posted at all - nor do I see any other Core Data related notifications after the initial load happens on startup.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload