For simplicity the Rest API, sends this JSON response-body= { "status" : "ok"}.
I set-up my Restkit mappings like... created a Class called StatusResponse which has one @property (nonatomic, assign) NSString *status;
RKObjectMapping *statusResponseMapping = [RKObjectMapping mappingForClass:[StatusResponse class]];
[statusResponseMapping addAttributeMappingsFromDictionary:@{@"status":@"status"}];
// also tried : [statusResponseMapping addAttributeMappingsFromDictionary:@[@"status"]]; which resulted in same error
NSIndexSet *statusCodes = RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful);
RKResponseDescriptor *statusResponseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:statusResponseMapping method:RKRequestMethodPOST pathPattern:@"status" keyPath:nil statusCodes:statusCodes];
[[RKObjectManager sharedManager] addResponseDescriptor:statusResponseDescriptor];
I'm running a post which is successful, but I get this error back:
NSUnderlyingError=0x17024d440 "No mappable object representations were found at the key paths searched.", keyPath=null, NSLocalizedDescription=No response descriptors match the response loaded.}
response.body={
"status": "ok"
}
Any help with this would be appreciated.
You should try keyPath to @"" and pathPattern as nil, here is piece of Code I am using which is perfectly working fine for me. I am doing exactly same you are trying to do.
RKResponseDescriptor *statusResponseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:[ResponseStatus rkObjectMappingForResponse:YES] method:RKRequestMethodAny pathPattern:nil keyPath:@"" statusCodes:statusCodes];