I am saving objects in core data which is in the below format.
{
"propertyId": 1,
"name": "some_name_1",
"userName": "some_email_1"
},
{
"propertyId": 1,
"name": "some_name_2",
"userName": "some_email_2"
},
{
"propertyId": 2,
"name": "some_name_3",
"userName": "some_email_3"
},
{
"propertyId": 2,
"name": "some_name_4",
"userName": "some_email_4"
},
{
"propertyId": 3,
"name": "some_name_5",
"userName": "some_email_5"
},
{
"propertyId": 3,
"name": "some_name6_",
"userName": "some_email_6"
}
Now, the problem is that only the last object from the group of the same propertyId is getting saved in the Core Data.
This is the code I got from the previous developer. Mapping is used to store data.
RKEntityMapping *rkEntityMapping = [RKEntityMapping mappingForEntityForName:@"PropertyAssignee" inManagedObjectStore:self.managedObjectStore];
rkEntityMapping.identificationAttributes = @[@"propertyId"];
[rkEntityMapping addAttributeMappingsFromDictionary:@{
@"propertyId": @"propertyId",
@"name": @"name",
@"userName": @"userName"}];
[rkEntityMapping addConnectionForRelationship:@"property" connectedBy:@{@"propertyId": @"objId"}];
RKObjectMapping *syncMapping = [RKObjectMapping mappingForClass:[NSMutableDictionary class]];
[syncMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"propertyAssgineeResponse" toKeyPath:@"propertyAssgineeResponse" withMapping:propertAssigneeMapping]];
RKResponseDescriptor *responseDescriptorProperties = [RKResponseDescriptor responseDescriptorWithMapping:syncMapping method:RKRequestMethodAny pathPattern:@"/api/sync" keyPath:nil statusCodes:[NSIndexSet indexSetWithIndex:200]];
[self.objectManager addResponseDescriptor:responseDescriptorProperties];
I am not getting any clue of why this is happening.