mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-28 20:55:32 +08:00
Committing changes to sync against 0.9
This commit is contained in:
@@ -15,8 +15,8 @@
|
||||
#pragma mark -
|
||||
#pragma mark NSManagedObject helper methods
|
||||
|
||||
// TODO: The managedObjectContext should be settable at the class level to ease coupling with
|
||||
// singleton object manager
|
||||
// TODO: The object store should be settable at the class level to ease coupling with
|
||||
// shared object manager
|
||||
+ (NSManagedObjectContext*)managedObjectContext {
|
||||
return [[[RKObjectManager sharedManager] objectStore] managedObjectContext];
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
* map to a given request URL.
|
||||
*/
|
||||
@protocol RKManagedObjectCache
|
||||
@required
|
||||
|
||||
/**
|
||||
* Must return an array containing NSFetchRequests for use in retrieving locally
|
||||
|
||||
@@ -31,7 +31,7 @@ extern NSString* const RKManagedObjectStoreDidFailSaveNotification;
|
||||
|
||||
/*
|
||||
* This returns an appropriate managed object context for this object store.
|
||||
* Because of the intrecacies of how CoreData works across threads it returns
|
||||
* Because of the intrecacies of how Core Data works across threads it returns
|
||||
* a different NSManagedObjectContext for each thread.
|
||||
*/
|
||||
@property (nonatomic, readonly) NSManagedObjectContext* managedObjectContext;
|
||||
@@ -71,5 +71,12 @@ extern NSString* const RKManagedObjectStoreDidFailSaveNotification;
|
||||
*/
|
||||
- (RKManagedObject*)findOrCreateInstanceOfManagedObject:(Class)class withPrimaryKeyValue:(id)primaryKeyValue;
|
||||
|
||||
/**
|
||||
* Returns an array of objects that the 'live' at the specified resource path. Usage of this
|
||||
* method requires that you have provided an implementation of the managed object cache
|
||||
*
|
||||
* See managedObjectCache above
|
||||
*/
|
||||
- (NSArray*)objectsForResourcePath:(NSString*)resourcePath;
|
||||
|
||||
@end
|
||||
|
||||
@@ -241,4 +241,15 @@ static NSString* const kRKManagedObjectContextKey = @"RKManagedObjectContext";
|
||||
return object;
|
||||
}
|
||||
|
||||
- (NSArray*)objectsForResourcePath:(NSString *)resourcePath {
|
||||
NSArray* cachedObjects = nil;
|
||||
|
||||
if (self.managedObjectCache) {
|
||||
NSArray* cacheFetchRequests = [self.managedObjectCache fetchRequestsForResourcePath:resourcePath];
|
||||
cachedObjects = [RKManagedObject objectsWithFetchRequests:cacheFetchRequests];
|
||||
}
|
||||
|
||||
return cachedObjects;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -130,6 +130,9 @@ static const NSString* kRKModelMapperMappingFormatParserKey = @"RKMappingFormatP
|
||||
if (keyPath) {
|
||||
object = [object valueForKeyPath:keyPath];
|
||||
}
|
||||
|
||||
// TODO: Calling into mapObjectFromDictionary here causes registration lookup even if class is populated
|
||||
// TODO: need mapInstanceOfClass: fromDictionary:
|
||||
if ([object isKindOfClass:[NSDictionary class]]) {
|
||||
return [self mapObjectFromDictionary:(NSDictionary*)object];
|
||||
} else if ([object isKindOfClass:[NSArray class]]) {
|
||||
@@ -193,6 +196,8 @@ static const NSString* kRKModelMapperMappingFormatParserKey = @"RKMappingFormatP
|
||||
}
|
||||
|
||||
// TODO: Can I make this support keyPath??
|
||||
// Lookup an object type using the element to class mappings and map its attributes
|
||||
// Expects an object of the form {"registered_type": {"attribute1": "value", "attribute2": "value"}
|
||||
- (NSObject<RKObjectMappable>*)mapObjectFromDictionary:(NSDictionary*)dictionary {
|
||||
NSString* elementName = [[dictionary allKeys] objectAtIndex:0];
|
||||
Class class = [_elementToClassMappings objectForKey:elementName];
|
||||
|
||||
@@ -1879,6 +1879,7 @@
|
||||
GCC_PREFIX_HEADER = Code/Support/RestKit_Prefix.pch;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 3.0;
|
||||
OTHER_LDFLAGS = "-ObjC";
|
||||
PREBINDING = NO;
|
||||
SDKROOT = iphoneos;
|
||||
@@ -1896,6 +1897,7 @@
|
||||
GCC_PREFIX_HEADER = Code/Support/RestKit_Prefix.pch;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 3.0;
|
||||
OTHER_LDFLAGS = "-ObjC";
|
||||
PREBINDING = NO;
|
||||
SDKROOT = iphoneos;
|
||||
|
||||
Reference in New Issue
Block a user