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)];
ペーストビンのコンソール出力と、ここにアクセスできる JSON 応答の例
助けてくれてありがとう、ルイス