我将对象休息为:
@interface VFEQuestionnaireRest : NSObject
@property(copy ,nonatomic) NSNumber *iid;
@property(copy, nonatomic)NSString *namePoll;
@property(copy, nonatomic)NSSet *questions;
@end
并将JSON作为:
{"questionnaire":[
{"id":4,"namePoll":"questionario4","questions":
{"id":13,"idQuestionnaire":4,"nameQuestion":"costo?",
"questionType":{"id":2,"nameType":"WHOLE"}}}]}
值“iid”始终为“0”,namePoll 具有正确的值。如何将 int 值从 JSON 映射到NSNumber
objC?
-
RKObjectMapping *questionnaireMapping = [RKObjectMapping mappingForClass:[VFEQuestionnaireRest class]];
[questionnaireMapping addAttributeMappingsFromDictionary:
@{@"iid":@"id",
@"namePoll":@"namePoll"
}];
[questionnaireMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"questions" toKeyPath:@"questions" withMapping:questionMapping]];