我正在使用 RESTKIT 将服务器端的属性映射到客户端的属性。
当 RESTKIT 尝试将 NULL 值从服务器映射到客户端的 NSUInteger 属性时,我遇到了 [NSNull unsignedIntValue] 错误。
例如:
//User object property "new_questions_count" defined on client side with NSUInteger property
@interface User : NSObject <NSCoding>
{
NSUInteger new_questions_count;
}
@property (nonatomic, assign) NSUInteger new_questions_count;
@end
//User Object Mapping - mapping "new_question_count" to server's json value
RKObjectMapping* userMapping = [RKObjectMapping mappingForClass:[User class]];
[userMapping mapAttributes:@"new_question_count",nil];
[provider setMapping:userMapping forKeyPath:@"user"];
对于上述情况,如果 json 值为 "new_questions_count":null,我将遇到 [NSNull unsignedIntValue] 错误。
如何在客户端进行检查并解决此问题,而无需更改服务器端的实现?