After spending a lot of hours with this error I come here to ask if somebody have some information about this error. I load two entities, a Parks entity and a GuidedTour entity. A Paks can be relatet to many GuidedTours but when I try to save it, the error raises:
Error Domain=NSCocoaErrorDomain Code=133020 "(null)" UserInfo={conflictList=( "NSMergeConflict (0x17026afc0) for NSManagedObject (0x1740d94b0) with objectID '0xd000000000240002 ' with oldVersion = 0 and newVersion = and old cached row = {\n language = \"de_DE\";\n text = \"Apapapapapa"...}
I can't understand what is wrong, my Merge policy is: NSMergeByPropertyStoreTrumpMergePolicyType
And my code:
AppDelegate appDelegate = (AppDelegate)[[UIApplication sharedApplication] delegate]; self.context = [appDelegate managedObjectContext];
NSError *error = nil;
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"GuidedTours" inManagedObjectContext:self.context ];
[fetchRequest setEntity:entity];
NSArray *fetchedObjects = [self.context executeFetchRequest:fetchRequest error:&error];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"guided_tours_parks == NULL"];
fetchedObjects = [fetchedObjects filteredArrayUsingPredicate:predicate];
GuidedTours *tour = [fetchedObjects firstObject];
fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entityPark = [NSEntityDescription entityForName:@"Parks" inManagedObjectContext:self.context ];
[fetchRequest setEntity:entityPark];
fetchedObjects = [self.context executeFetchRequest:fetchRequest error:&error];
predicate = [NSPredicate predicateWithFormat:@"name == %@",[jsonData objectForKey:@"Park ID"] ];
fetchedObjects = [fetchedObjects filteredArrayUsingPredicate:predicate];
Parks *park = [fetchedObjects firstObject];
[tour setGuided_tours_parks:park];
[park addParks_guided_toursObject:tour];
// Save the object to persistent store
if (![self.context save:&error]) {
NSLog(@"Can't Save! %@ %@", error, [error localizedDescription]);
}
Does somebody have any idea?
Thank you!