I have this issue, that i'm mapping all object properly, but the properties that are inside the root object, for some reason I cannot map.
This is the JSON:
{
"responseError": null,
"responseIsRegisteredServices": {
"registeredToServiceAntiVirus": true,
"registeredToServiceCloud": true,
"registeredToServiceMusic": true,
"registeredToServiceSong": true,
"registeredToServiceTv": true
},
"responseRegisteredServicesCloud": null,
"responseRegisteredServicesMusic": [
{
"ID": null,
"Name": null,
"AlbumPic": "110_110.png",
"ArtistName": "Rihanna"
},
{
"ID": null,
"Name": null,
"AlbumPic": "110_110.png",
"ArtistName": "Rihanna"
},
{
"ID": null,
"Name": null,
"AlbumPic": "110_110.png",
"ArtistName": "Steve Angello"
}
]
}
This is the RegisteredServices class:
@interface RegisteredServices : NSObject
@property (nonatomic) ResponseError *responseError;
@property (nonatomic) NSNumber *registeredToServiceAntiVirus;
@property (nonatomic) NSNumber *registeredToServiceCloud;
@property (nonatomic) NSNumber *registeredToServiceMusic;
@property (nonatomic) NSNumber *registeredToServiceSong;
@property (nonatomic) NSNumber *registeredToServiceTv;
@property (nonatomic) CloudServices *responseRegisteredServicesCloud;
@property (nonatomic) NSArray *responseRegisteredServicesMusix;
@end
This is the 'CloudServices' class:
@interface CloudServices : NSObject
@property (nonatomic) NSString *capacityType;
@property (nonatomic) NSNumber *currentCapacity;
@property (nonatomic) NSString *lastBackupDate;
@property (nonatomic) NSNumber *percentage;
@property (nonatomic) NSNumber *totalCapacity;
@end
This is the 'MusicServices' class:
@interface MusicServices : NSObject
@property (nonatomic) NSNumber *idNum;
@property (nonatomic) NSString *name;
@property (nonatomic) NSString *albumPic;
@property (nonatomic) NSString *artistName;
@end
This is the mapping itself:
RKObjectMapping *musixMapping = [RKObjectMapping mappingForClass:[MusicServices class]];
[musicMapping addAttributeMappingsFromDictionary:@{ @"ID" : @"idNum",
@"Name" : @"name",
@"AlbumPic" : @"albumPic",
@"ArtistName" : @"artistName" }];
RKObjectMapping *cloudMapping = [RKObjectMapping mappingForClass:[CloudServices class]];
[cloudMapping addAttributeMappingsFromDictionary:@{@"capacityType": @"capacityType",
@"currentCapacity": @"currentCapacity",
@"lastBackupDate": @"lastBackupDate",
@"percentage": @"percentage",
@"totalCapacity": @"totalCapacity" }];
RKObjectMapping *registeredServicesMapping = [RKObjectMapping mappingForClass:[RegisteredServices class]];
[registeredServicesMapping addAttributeMappingsFromDictionary:@{ @"registeredToServiceAntiVirus" : @"registeredToServiceAntiVirus",
@"registeredToServiceCloud" : @"registeredToServiceCloud",
@"registeredToServiceMusic" : @"registeredToServiceMusic",
@"registeredToServiceSong" : @"registeredToServiceSong",
@"registeredToServiceTv" : @"registeredToServiceTv", }];
[registeredServicesMapping addRelationshipMappingWithSourceKeyPath:@"responseRegisteredServicesMusic" mapping:musixMapping];
[registeredServicesMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"responseError"
toKeyPath:@"responseError"
withMapping:errorMapping]];
[registeredServicesMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"responseRegisteredServicesCloud"
toKeyPath:@"responseRegisteredServicesCloud"
withMapping:cloudMapping]];
[[RKObjectManager sharedManager] addResponseDescriptor:[RKResponseDescriptor responseDescriptorWithMapping:registeredServicesMapping
method:RKRequestMethodGET
pathPattern:@"registeredServices"
keyPath:nil
statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)]];
Can't figure out what seems to be the problem. When I add responseIsRegisteredServices into the keyPath: of the RKResponseDescriptor than the MusicServices array is null.
Thanks in advance.