mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-23 20:31:13 +08:00
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:
committed by
Blake Watters
parent
0660f28fc1
commit
1cd22d5b33
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user