Last active
August 29, 2015 14:06
-
-
Save wethu/2c6a7dfcbbc62af9dd36 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "CPRObjectLoader.h" | |
#import "CPRObjectManager.h" | |
#import "CPRPersistentStack.h" | |
// Added these to see if the frameworks wernt' getting linked but they were | |
#import <CoreData/CoreData.h> | |
#import <RestKit/RestKit.h> | |
@interface CPRObjectLoader() | |
@end | |
@implementation CPRObjectLoader | |
- (id)init { | |
return [self initWithPathPattern:nil forKeyPath:nil withParams:nil withMapping:nil]; | |
} | |
- (id)initWithPathPattern:(NSString *)pathPattern forKeyPath: (NSString *)keyPath withParams:(NSDictionary *)requestParameters withMapping:(RKMapping *)mapping { | |
self = [super init]; | |
if (self) { | |
NSLog(@"Object Loader initalized"); | |
_pathPattern = pathPattern; | |
_keyPath = keyPath; | |
_requestParameters = requestParameters; | |
_mapping = mapping; | |
[self startOperation]; | |
} | |
return self; | |
} | |
#pragma mark - private methods | |
-(void)startOperation { | |
NSIndexSet *statusCodes = RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful); | |
RKObjectManager *objectManager = [CPRObjectManager comprintObjectManager]; | |
NSURLRequest *request = [objectManager requestWithObject:nil method:RKRequestMethodGET path:self.pathPattern parameters:self.requestParameters]; | |
RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:self.mapping method:RKRequestMethodAny pathPattern:self.pathPattern keyPath:self.keyPath statusCodes:statusCodes]; | |
// The line below works and theres no forward declaration at all: | |
RKObjectRequestOperation *operation = [[RKObjectRequestOperation alloc] initWithRequest:request responseDescriptors:@[responseDescriptor]]; | |
// This is straight from RK Docs: https://github.com/RestKit/RestKit - Section: Managed Object Request | |
// ERROR: http://gyazo.com/89ae7db26a367f0416c47549b6ea8cf3 | |
RKManagedObjectRequestOperation *operation = [[RKManagedObjectRequestOperation alloc] initWithRequest:request responseDescriptors:@[responseDescriptor]]; | |
RKManagedObjectStore *store = [[CPRPersistentStack sharedDataModel] objectStore]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment