NSURL *baseURL = [NSURL URLWithString:@"https://api.vk.com/method/"];
AFHTTPClient *client = [[AFHTTPClient alloc] initWithBaseURL:baseURL];
RKObjectManager *objectManager = [[RKObjectManager alloc] initWithHTTPClient:client];
RKObjectMapping *profilesMapping = [RKObjectMapping mappingForClass:[Profiles class]];
[profilesMapping addAttributeMappingsFromArray:@[@"uid",
@"first_name",
@"last_name",
@"photo_max"]];
RKResponseDescriptor *responseDescriptor =
[RKResponseDescriptor responseDescriptorWithMapping:profilesMapping
method:RKRequestMethodGET
pathPattern:@"users.get?user_id=1"
keyPath:@"response"
statusCodes:[NSIndexSet indexSetWithIndex:200]];
[objectManager addResponseDescriptor:responseDescriptor];
NSDictionary *params = @{@"fields": @"photo_max"};
[[RKObjectManager sharedManager] getObjectsAtPath:@"users.get?user_id=1"
parameters:params
success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult){
NSLog(@"%@", mappingResult.array);
}
failure:^(RKObjectRequestOperation *operation, NSError *error){
NSLog(@"%@", error);
NSLog(@":c");
}
];
No mappable object representations were found at the key paths searched.", keyPath=null, NSLocalizedDescription=No response descriptors match the response loaded.
RKObjectMapping *profilesMapping = [RKObjectMapping mappingForClass:[LVKUser class]];
[profilesMapping addAttributeMappingsFromArray:@[@"uid",
@"first_name",
@"last_name",
@"nickname"]];
RKResponseDescriptor *responseDescriptor =
[RKResponseDescriptor responseDescriptorWithMapping:profilesMapping
method:RKRequestMethodGET
pathPattern:@"users.get"
keyPath:@"response"
statusCodes:[NSIndexSet indexSetWithIndex:200]];
[objectManager addResponseDescriptor:responseDescriptor];
NSDictionary *params = @{@"fields": @"nickname", @"user_id": @"1"};
[[RKObjectManager sharedManager] getObjectsAtPath:@"users.get"
parameters:params
success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult){
NSLog(@"%@", mappingResult.array);
}
failure:^(RKObjectRequestOperation *operation, NSError *error){
NSLog(@"%@", error);
NSLog(@":c");
}
];