1
我一直在尝试从JSON响应映射下面的对象,并从控制台输出中看到的所有内容中,没有任何理由为什么映射不是“T成功 - 我很感激,如果任何人都可以有一个检查,看看:RestKit - 不是键值编码兼容,在JSON中没有根
@interface RKElectionsModel : NSObject
@property (nonatomic, assign) bool isActive;
@property (nonatomic, strong) NSNumber *electionID;
@property (nonatomic, strong) NSString *title;
@property (nonatomic, strong) NSString *summary;
@property (nonatomic, strong) NSNumber *availableSeats;
@property (nonatomic, strong) NSNumber *candidatesCount;
@property (nonatomic, strong) NSNumber *withdrawnCount;
@property (nonatomic, strong) NSSet *candidates;
@end
/**
* Election Detail Mapping: Getting all election details, we have some extra information from
* the API call
*
*/
RKObjectMapping *electionDetailsMapping = [RKObjectMapping mappingForClass:[RKElectionsModel class]];
// Map JSON -> entities
[electionDetailsMapping addAttributeMappingsFromDictionary:@{
@"id": @"electionID",
@"title": @"title",
@"summary": @"summary",
@"active": @"isActive",
@"availableSeats": @"availableSeats",
@"candidatesCount": @"candidatesCount",
@"withdrawnCount": @"withdrawnCount"
}];
// Register our mappings with the provider
RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:electionDetailsMapping pathPattern:@"/api/elections/:electionID/all" keyPath:nil statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
Console output上引擎收录和JSON响应的任何实例,您可以访问here
得到任何帮助, 刘易斯