Created
May 24, 2014 22:04
-
-
Save fogonthedowns/9fd2d8ca3cfbe124e3fd 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 "snapApi.h" | |
#import <RestKit/RestKit.h> | |
#import "Profile.h" | |
@interface snapApi () | |
@property (nonatomic, strong) NSArray *profile; | |
@end | |
@implementation snapApi | |
-(instancetype)initWithconfigureRestKit:className objectMapping:(NSDictionary *)dictionary httpMethod:method { | |
self = [super init]; | |
if (self) { | |
// initialize AFNetworking HTTPClient | |
NSURL *baseURL = [NSURL URLWithString:@"https://myserver.com"]; | |
AFHTTPClient *client = [[AFHTTPClient alloc] initWithBaseURL:baseURL]; | |
// initialize RestKit | |
RKObjectManager *objectManager = [[RKObjectManager alloc] initWithHTTPClient:client]; | |
// setup object mappings | |
RKObjectMapping *venueMapping = [RKObjectMapping mappingForClass:[className class]]; | |
[venueMapping addAttributeMappingsFromDictionary:dictionary]; | |
// register mappings with the provider using a response descriptor | |
RKResponseDescriptor *responseDescriptor = | |
[RKResponseDescriptor responseDescriptorWithMapping:venueMapping | |
method:method | |
pathPattern:@"/new" | |
keyPath:nil | |
statusCodes:[NSIndexSet indexSetWithIndex:200]]; | |
[objectManager addResponseDescriptor:responseDescriptor]; | |
} | |
return self; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment