I have an app with core data and icloud to allow the user to use the same database on several devices. The sync works most of the time perfect, but sometimes it doesn't, i.e. some transactions are simply skipped.
When I check the console, I get the error message:
__45-[PFUbiquityFilePresenter processPendingURLs]_block_invoke(439): CoreData: Ubiquity: Librarian returned a serious error for starting downloads Error Domain=BRCloudDocsErrorDomain Code=5 "The operation couldn’t be completed. (BRCloudDocsErrorDomain error 5 - No document at URL)"
Funny enough this message appears even when the sync works.
The code fits to Apple latest version of " iCloud Programming Guide for Core Data". The storeURL is coded as follows:
NSURL *documentsDirectory = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
NSURL *storeURL = [documentsDirectory URLByAppendingPathComponent:@"iCloudSample.sqlite"];
The code for the options:
storeOptions = @{NSPersistentStoreUbiquitousContentNameKey: @"iCloudSampleStore" ,
NSPersistentStoreUbiquitousContentURLKey: @"iCloudSampleURL"};
The code for the store:
NSPersistentStore *store = [_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType
configuration:nil
URL:storeURL
options:storeOptions
error:&error];
The merge policy (MOC is on the main qeue)
_managedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType];
[_managedObjectContext setPersistentStoreCoordinator:coordinator];
_managedObjectContext.mergePolicy = [[NSMergePolicy alloc]
initWithMergeType:NSMergeByPropertyObjectTrumpMergePolicyType];
As I understand the docs, there is not really much more to do(?). But I guess I'm missing something, does anyone has an idea what to check, change, try? Anyone who had the same problem? Any ideas are appreciated!