Search code examples
core-dataicloud

How to check if the content has backed up on the iCloud (core data)


According to this tutorial Core Data in iCloud

I detect the new version updated content in mergeChangesFrom_iCloud method like this

(void)mergeChangesFrom_iCloud:(NSNotification *)notification {

    NSLog(@"Merging in changes from iCloud...");
    NSLog(@"New Version has been detected! so update UI status then");

Code above works fine if I use another device to check the updated contents. (Posted by iPhone and used iPad to see the update.

How to know if the content has been backed up on the iCloud? I would like to update my UI right after adding the content.

Thank you in advance.


Solution

  • In short: You don't know.

    When you save changes to an iCloud-enabled persistent store, those changes are sent to the cloud separately by ubd, the ubiquity daemon. You don't get any notification of when or if this has happened.

    It would probably be hard to make sense of such a notification anyway, since network issues might delay sending the changes. You might save changes repeatedly when it's impossible to send them to the cloud server. Then you get a notification-- but which save does that correspond to? No doubt it would be possible to reconfigure the Core Data API to assign each save call a unique ID, but Apple hasn't done this.