IOS Restkit null映射结果

时间:2013-09-12 10:03:06

标签: ios restkit-0.20

我无法使用RestKit将我的JSON映射到模型。 XCode上的记录器说

2013-09-12 16:35:00.543 EMoney[1291:342f] T restkit.object_mapping:RKMappingOperation.m:902 Performing mapping operation: <RKMappingOperation 0x20155890> for 'EMEcommerceInquiryResponse' object. Mapping values from object {
} to object *nil description* with object mapping (null)
2013-09-12 16:35:00.550 EMoney[1291:342f] T restkit.object_mapping:RKMappingOperation.m:571 Did not find mappable attribute value keyPath 'status'

这是json回复

response.body={"status":"NOT_ENOUGH_CREDITS","statusdesc":"no credits"}

这是我的映射代码

RKObjectMapping *ecommerceInquiryMapping = [RKObjectMapping mappingForClass:[EMEcommerceInquiryResponse class]];
    [ecommerceInquiryMapping addAttributeMappingsFromArray:@[@"status",@"statusdesc"]];
    RKResponseDescriptor *responseEcommerceInquiryDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:ecommerceInquiryMapping
                                                                                                   pathPattern:EM_API_SPECIAL_OFFER_INQUIRY
                                                                                                       keyPath:nil
                                                                                                   statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
    [objectManager addResponseDescriptor:responseEcommerceInquiryDescriptor];

这是我的对象类

#import <Foundation/Foundation.h>

@interface EMEcommerceInquiryResponse : NSObject
@property (retain, nonatomic) NSString *status;
@property (retain, nonatomic) NSString *statusdesc;
@end

这是我尝试打印状态时的日志

2013-09-12 17:06:55.042 EMoney[1343:907] STATUS (null)

任何人都知道我的代码有什么问题?我对其他映射使用类似的代码,它们工作正常。

0 个答案:

没有答案