RESTKit で GET リクエストを実行していますが、オブジェクト マッピングを実行しても機能しません。ただし、マッピング結果で1つのオブジェクトをマッピングしたと常に言われますが、それが何であるか、または残りのオブジェクトをマッピングする方法がわかりません。マッピング結果がマッピングされた 1 つのオブジェクトとして表示される原因と、適切なすべてのオブジェクトをマッピングする方法を教えてください。
マッピング結果は次のとおりです。
Mapping Result: (
"<Info: 0x9c91130>"
)
これが私のGETリクエストです: //RK Logging RKLogConfigureByName("RestKit/Network", RKLogLevelTrace);
NSIndexSet *statusCodeSet = RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful);
NSString *urlString = [NSString stringWithFormat:@"https://beta.stuff.com/"];
NSURL *url = [NSURL URLWithString:urlString];
//Object Mapping
RKObjectMapping *mapping = [RKObjectMapping mappingForClass:[Info class]];
[mapping addAttributeMappingsFromDictionary:@{@"name": @"name", @"id": @"strenuusID", @"location_specialties.address": @"address", @"location_specialties.state": @"state", @"location_specialties.zip": @"zipcode", @"location_specialties.address_lines": @"address_lines"}];
NSString *pathPatternString = [NSString stringWithFormat:@"stuff/%@/stuff2/%@/", moreresultsVCSobj.projectNumber, moreresultsVCSobj.doctorStuff];
//Response Descriptor
RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:mapping
method:RKRequestMethodGET
pathPattern:pathPatternString
keyPath:@""
statusCodes:statusCodeSet];
RKObjectManager *manager = [RKObjectManager managerWithBaseURL:url];
[manager addResponseDescriptor:responseDescriptor];
[manager.HTTPClient setDefaultHeader:@"Auth-Token" value:moreresultsVCSobj.userAuthToken];
Info *info = [Info new];
[manager getObject:info path:pathPatternString parameters:nil success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult)
{
NSLog(@"Mapping Result: %@", mappingResult.array);
} failure:^(RKObjectRequestOperation *operation, NSError *error)
{
NSLog(@"Error: %@", error);
}];
私が解析しているJSONは次のとおりです。
response.body=
{
"name": "Name, Generic N, DDS",
"id": 123456,
"npi": "1234567890",
"hospitality": false,
"groupiness": [
"Other"
],
"client_ids": null,
"has_comments": false,
"comment_count": 0,
"is_facility": false,
"location_specialties": [
{
"id": 123456,
"address_id": 454345,
"address": "1234 Rifle Rd",
"state": "Al",
"zip": "43543",
"address_lines": [
"1234 Rifle Rd",
"Generic Town, Al 43543",
"111-222- 3344"
],
"latitude": 21432234,
"longitude": 432432,
"is_validated": true,
"providers_at_address_count": 2,
"specialties": [
{
"name": "Dentists",
"plans": [
{
"name": "Plan name",
"lists_specialty": true
},
{
"name": "Plane name 2",
"lists_specialty": true
},
{
"name": "Plan name 3",
"lists_specialty": true
}
]
}
]
},
[
{
"id": 123456,
"address_id": 454345,
"address": "1234 Rifle Rd",
"state": "Al",
"zip": "43543",
"address_lines": [
"1234 Rifle Rd",
"Generic Town, Al 43543",
"111-222- 3344"
],
"latitude": 21432234,
"longitude": 432432,
"is_validated": true,
"providers_at_address_count": 2,
"specialties": [
{
"name": "Dentists",
"plans": [
{
"name": "Plan name",
"lists_specialty": true
},
{
"name": "Plane name 2",
"lists_specialty": true
},
{
"name": "Plan name 3",
"lists_specialty": true
}
]
}
]
},
"hospital_detail": null,
"tags": [
]
}
編集: ここに私の Info.h ファイルがあります。名前などのマッピングを確認しようとしましたが、まだ機能しません。
#import <Foundation/Foundation.h>
@interface Info : NSObject
@property (nonatomic, copy) NSString *name;
@property (nonatomic, copy) NSString *strenuusID;
@property (nonatomic, copy) NSString *npi;
@property (nonatomic, copy) NSArray *specialty_search_groups;
@property (nonatomic, copy) NSArray *address_lines;
@property (nonatomic, copy) NSArray *address;
@property (nonatomic, copy) NSString *state;
@property (nonatomic, copy) NSString *zipcode;
@property (nonatomic, copy) NSString *planName;
@end