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
得到任何幫助, 劉易斯