Core Data & iCloud Error: Unable to find relationship destination object

Stackoverflow link: http://stackoverflow.com/questions/31695187/core-data-icloud-error-unable-to-find-relationship-destination-object


I´ve been using Core Data and iCloud for a while in my app now. But its suddenly acting up like crazy. The problem is when a device should import new changes from iCloud i.e in the


- (void)persistentStoreDidImportUbiquitousContentChanges:(NSNotification *)notification


If I add 1 new entity on device A the entity will sync over to device B. But if I add multiple new entities at the same time only the one or two last will sync over to device B. This is when I get the error message:


Unable to find relationship destination object: [_PFUbiquityRecordImportOperation processObjects:withState:andImportContext:outError:](1017): CoreData: Ubiquity: <_PFUbiquityRecordImportOperation: 0x14694540>{name = '(null)'}


I am also printing whats about to change (the [notification userInfo]) and it looks like this when following that error message.



{ deleted = "{(\n)}"; inserted = "{(\n)}"; updated = "{(\n)}"; }



My model:

I have a Company that has Employees. No one of them has any delete rule in the .xcdatamodel. It is the Employees who is raising

Unable to find relationship destination object:
I seem to get some Employees with Company "null/nil"


This is how I retrieve my MOC:



if (managedObjectContext != nil) { 
     return managedObjectContext; 
} 
NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator];
 if (coordinator != nil) { 
     managedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType];                               [managedObjectContext setPersistentStoreCoordinator: coordinator]; 
[managedObjectContext setMergePolicy:NSMergeByPropertyObjectTrumpMergePolicy];
[managedObjectContext setStalenessInterval:0.0];
} 

return managedObjectContext;

And this is how I save to the MOC


  [context performBlockAndWait:^{ success = [context save:&error]; }];


My question is, have anyone else experienced this problem? How do I go about solving it? Any ideas that is moving me in the right direction is really appreciated. Put a comment if you want me to include more information about my problem.

Core Data & iCloud Error: Unable to find relationship destination object
 
 
Q