I load data from a json file, I save it. I do this twice ... I got two entries in the sqlite Core Data database. Even if I set primaryKeyAttribute to mapping.
mapping.primaryKeyAttribute = @"code"; [mapping mapAttributesFromArray :mappedFields]; [[RKObjectManager sharedManager].mappingProvider setMapping:mapping forKeyPath:entityName];
My json
{"MyEntity": [{"code": "axv2", "data": "content"}]};
Here's the callback:
- (void)objectLoader:(RKObjectLoader*)objectLoader didLoadObjects:(NSArray*)objects { NSLog(@"Entries loaded %d",[objects count]); lastResult = objects; for(MyEntity * myEntity in lastResult) { [self saveContext]; } }
My essence is correctly displayed ... But Restkit allows you to save duplicate entries with the same primary key?
Strange, I realized that this primary key attribute will avoid this problem.
Sam
source share