First pass at replacing RKManagedObjectCache with a more flexible block approach that leverages the new resource path pattern matching approach to registering objectMappings.

This commit is contained in:
Jeff Arena
2012-01-26 16:52:38 -05:00
committed by Blake Watters
parent 0660f28fc1
commit 1cd22d5b33
28 changed files with 1091 additions and 372 deletions

View File

@@ -156,14 +156,17 @@
}
// If we have found the primary key attribute & value, try to find an existing instance to update
if (primaryKeyAttribute && primaryKeyValue) {
object = [_objectStore findOrCreateInstanceOfEntity:entity withPrimaryKeyAttribute:primaryKeyAttribute andValue:primaryKeyValue];
NSAssert2(object, @"Failed creation of managed object with entity '%@' and primary key value '%@'", entity.name, primaryKeyValue);
} else {
if (primaryKeyAttribute && primaryKeyValue) {
object = [self.objectStore.cacheStrategy findInstanceOfEntity:entity
withMapping:self
andPrimaryKeyValue:primaryKeyValue
inManagedObjectContext:[self.objectStore contextForCurrentThread]];
}
if (object == nil) {
object = [[[NSManagedObject alloc] initWithEntity:entity
insertIntoManagedObjectContext:[_objectStore contextForCurrentThread]] autorelease];
}
return object;
}