Allow assertion to pass if localObject is returned nil

This commit is contained in:
Blake Watters
2013-02-07 17:37:14 -05:00
parent e7352f7919
commit a19f1a5ff1

View File

@@ -386,10 +386,11 @@ static inline NSManagedObjectID *RKObjectIDFromObjectIfManaged(id object)
if (objectID) {
if ([objectID isTemporaryID]) RKLogWarning(@"Performing object mapping to temporary target objectID. Results may not be accessible without obtaining a permanent object ID.");
NSManagedObject *localObject = [self.managedObjectContext existingObjectWithID:objectID error:&blockError];
NSAssert([localObject.managedObjectContext isEqual:self.managedObjectContext], @"Serious Core Data error: requested existing object with ID %@ in context %@, instead got an object reference in context %@. This may indicate that the objectID for your target managed object was obtained using `obtainPermanentIDsForObjects:error:` in the wrong context.", objectID, self.managedObjectContext, [localObject managedObjectContext]);
NSAssert(localObject == nil || [localObject.managedObjectContext isEqual:self.managedObjectContext], @"Serious Core Data error: requested existing object with ID %@ in context %@, instead got an object reference in context %@. This may indicate that the objectID for your target managed object was obtained using `obtainPermanentIDsForObjects:error:` in the wrong context.", objectID, self.managedObjectContext, [localObject managedObjectContext]);
if (! localObject) {
RKLogWarning(@"Failed to retrieve existing object with ID: %@", objectID);
RKLogCoreDataError(blockError);
return;
}
self.mapperOperation.targetObject = localObject;
} else {