mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-23 04:20:21 +08:00
initial pass at changing fetchRequest APIs to work with a collection of fetch requests; also performed some API cleanup on RKManagedModel
This commit is contained in:
@@ -35,7 +35,7 @@
|
||||
RKRequest* _request;
|
||||
RKResponse* _response;
|
||||
Class<RKObjectMappable> _objectClass;
|
||||
NSFetchRequest* _fetchRequest;
|
||||
NSArray* _fetchRequests;
|
||||
NSString* _keyPath;
|
||||
}
|
||||
|
||||
@@ -90,12 +90,12 @@
|
||||
@property (nonatomic, retain) NSObject<RKRequestSerializable>* params;
|
||||
|
||||
/**
|
||||
* Fetch request for loading cached objects. This is used to remove objects from the local persistent store
|
||||
* Fetch requests for loading cached objects. This is used to remove objects from the local persistent store
|
||||
* when model mapping operations are completed.
|
||||
*
|
||||
* TODO: May belong in an inherited subclass to isolate persistent/non-persistent mapping in the future.
|
||||
*/
|
||||
@property (nonatomic, retain) NSFetchRequest* fetchRequest;
|
||||
@property (nonatomic, retain) NSArray* fetchRequests;
|
||||
|
||||
/*
|
||||
* The keyPath property is an optional property to tell the mapper to map a subset of the response
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
@implementation RKObjectLoader
|
||||
|
||||
@synthesize mapper = _mapper, delegate = _delegate, fetchRequest = _fetchRequest,
|
||||
@synthesize mapper = _mapper, delegate = _delegate, fetchRequests = _fetchRequests,
|
||||
request = _request, response = _response, objectClass = _objectClass,
|
||||
source = _source, keyPath = _keyPath;
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
[_mapper release];
|
||||
[_request release];
|
||||
[_response release];
|
||||
[_fetchRequest release];
|
||||
[_fetchRequests release];
|
||||
[_keyPath release];
|
||||
[super dealloc];
|
||||
}
|
||||
@@ -173,8 +173,8 @@
|
||||
results = [NSArray arrayWithObjects:result, nil];
|
||||
}
|
||||
|
||||
if (self.fetchRequest) {
|
||||
NSArray* cachedObjects = [RKManagedObject objectsWithRequest:self.fetchRequest];
|
||||
if (self.fetchRequests) {
|
||||
NSArray* cachedObjects = [RKManagedObject objectsWithFetchRequests:self.fetchRequests];
|
||||
for (id object in cachedObjects) {
|
||||
if ([object isKindOfClass:[RKManagedObject class]]) {
|
||||
if (NO == [results containsObject:object]) {
|
||||
|
||||
@@ -237,9 +237,9 @@ static const NSString* kRKModelMapperMappingFormatParserKey = @"RKMappingFormatP
|
||||
NSMutableDictionary* threadDictionary = [[NSThread currentThread] threadDictionary];
|
||||
|
||||
if (nil == [threadDictionary objectForKey:class]) {
|
||||
NSFetchRequest* fetchRequest = [class request];
|
||||
NSFetchRequest* fetchRequest = [class fetchRequest];
|
||||
[fetchRequest setReturnsObjectsAsFaults:NO];
|
||||
objects = [class objectsWithRequest:fetchRequest];
|
||||
objects = [class objectsWithFetchRequest:fetchRequest];
|
||||
NSLog(@"Cacheing all %d %@ objects to thread local storage", [objects count], class);
|
||||
NSMutableDictionary* dictionary = [NSMutableDictionary dictionary];
|
||||
NSString* primaryKey = [class performSelector:@selector(primaryKey)];
|
||||
|
||||
Reference in New Issue
Block a user