Allow late arriving child records to be related to correct parent #234

Closed
wants to merge 1 commit into
from
Jump to file or symbol
Failed to load files and symbols.
+4 −0
Split
@@ -212,6 +212,9 @@ - (BOOL) MR_importValuesForKeysWithObject:(id)objectData
{
NSEntityDescription *entityDescription = [relationshipInfo destinationEntity];
relatedObject = [entityDescription MR_createInstanceInContext:[self managedObjectContext]];
+ NSString *primaryKey = [relationshipInfo MR_primaryKey];
+ id relatedValue = [localObjectData MR_relatedValueForRelationship:relationshipInfo];
+ [relatedObject setValue:relatedValue forKey:primaryKey];
}
[relatedObject MR_importValuesForKeysWithObject:localObjectData];
@@ -231,6 +234,7 @@ + (id) MR_importFromObject:(id)objectData inContext:(NSManagedObjectContext *)co
if (managedObject == nil)
{
managedObject = [self MR_createInContext:context];
+ [managedObject setValue:value forKey:[primaryAttribute name]];
}
[managedObject MR_importValuesForKeysWithObject:objectData];