What does iCloud do during initial sync?

I want to sync my Core Data boot app with iCloud. Apple's sample project shows how to configure NSPsistentStoreCoordinator to enable iCloud. The code roughly looks like this:

persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel: [self managedObjectModel]]; NSDictionary* options = [NSDictionary dictionaryWithObjectsAndKeys:@"com.company.app", NSPersistentStoreUbiquitousContentNameKey, cloudURL, NSPersistentStoreUbiquitousContentURLKey,nil]; [psc addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:options error:&error]); 

The problem is that if the data is already saved in iCloud, this method will permanently return persistentStoreCoordinator. If I do it synchronously, I look at a blank screen for several minutes, if I do it asynchronously, my application is completely unusable because I cannot interact with Core Data.

Of course, I could add a permanent store, as I would without iCloud, and then let iCloud work asynchronously?

Basically, my question is what does iCloud do for the time it takes for the initial synchronization, and can I use persistentStoreCoordinator first and let the data sync in the background?

+4
source share
1 answer

When you use iCloud to sync Core Data, you need to load the storage into a separate stream. Take a look at:

https://devforums.apple.com/thread/126670

This demonstrates asynchronous storage loading.

+2
source

Source: https://habr.com/ru/post/1379752/


All Articles