This is my response body:
{
"bsqn": 5,
"results": [
{
"sqn": 1,
"res": "oldu!"
}
]
}
I wanna get through for "res" property which i really need, by using this keyPath:"bsqn.res"
//TestResponse.h
@interface TestResponse : NSObject
@property (nonatomic, copy) NSString *res;
+ (RKObjectMapping *)objectMapping;
@end
// TestResponse.m
@implementation TestResponse
+ (RKObjectMapping *)objectMapping
{
RKObjectMapping *mapping = [RKObjectMapping mappingForClass:[self class]];
[mapping addAttributeMappingsFromDictionary:@{@"res": @"res"}];
return mapping;
}
@end
RKResponseDescriptor *newDesc = [RKResponseDescriptor responseDescriptorWithMapping:
[TestResponse objectMapping] method:RKRequestMethodPOST pathPattern:nil keyPath:@"bsqn.res"
statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
But it gives this error:
this class is not key value coding-compliant for the key hashcode
Is there a way to do what i want? Thanks..
RKObjectMapping *mapping = [RKObjectMapping mappingForClass:[self class]];
I think[self class]
should be changed toself
since you are calling this in class method. – Eimantas