Skip to content

Instantly share code, notes, and snippets.

@fogonthedowns
Created May 24, 2014 22:04
Show Gist options
  • Save fogonthedowns/9fd2d8ca3cfbe124e3fd to your computer and use it in GitHub Desktop.
Save fogonthedowns/9fd2d8ca3cfbe124e3fd to your computer and use it in GitHub Desktop.
#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