Skip to content

Exception for missing relatedByAttribute. #263

Closed
wants to merge 1 commit into from
View
4 MagicalRecord/Categories/NSManagedObject/NSManagedObject+MagicalDataImport.m
@@ -236,6 +236,10 @@ + (id) MR_importFromObject:(id)objectData inContext:(NSManagedObjectContext *)co
{
NSAttributeDescription *primaryAttribute = [[self MR_entityDescription] MR_primaryAttributeToRelateBy];
+ NSAssert2(primaryAttribute != nil, @"Importing to the entity '%@' requires User Info key %@ to be set to an attribute name to avoid importing duplicate records.",
+ [[self MR_entityDescription] name],
+ kMagicalRecordImportRelationshipLinkedByKey);
+
id value = [objectData MR_valueForAttribute:primaryAttribute];
NSManagedObject *managedObject = [self MR_findFirstByAttribute:[primaryAttribute name] withValue:value inContext:context];
Something went wrong with that request. Please try again.