Foursquare (FS) 呼び出しの結果をマッピングしようとしています。AFNetworking を使用すると、FS の結果が期待どおり (JSON) に返されます。RKEntityMapping または RKObjectMapping を使用して Restkit で呼び出しを試みると、次のエラーが発生します。
RKMapperOperation.m:98 追加マッピング エラー: 属性または関係マッピングのマッピング可能な値が見つかりません
助言がありますか?何か不足していますか?一部の位置情報の関係マッピング設定がないことはわかっていますが、最上位のものをマッピングするようには見えません。
レストキット ===============
// --- VENUE MAPPING ------------------------------
RKEntityMapping *venueMapping = [RKEntityMapping mappingForEntityForName:@"Venue"
inManagedObjectStore:objectManager.managedObjectStore];
[venueMapping addAttributeMappingsFromArray:@[@"name"] ];
[venueMapping addAttributeMappingsFromDictionary:@{
@"id": @"venueID"
}];
[venueMapping setIdentificationAttributes:@[@"venueID"] ];
// Routes for Users
[self.foursquareManager.router.routeSet addRoute:[RKRoute routeWithClass:[Venue class]
pathPattern:@"v2/venues/search"
method:RKRequestMethodGET]];
// Register our mappings with the provider
RKResponseDescriptor *venueResponseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:venueMapping
pathPattern:@"v2/venues/search"
keyPath:nil
statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
RKResponseDescriptor *venueDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:venueMapping
pathPattern:@"v2/venues/search"
keyPath:nil
statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
[self.foursquareManager addResponseDescriptor:venueResponseDescriptor];
[self.foursquareManager addResponseDescriptor:venueDescriptor];
[self.foursquareManager getObject:nil
path:@"v2/venues/search"
parameters:@{
@"client_id" : kFourSquareClientID,
@"client_secret" : kFourSquareClientSecret,
@"ll" : searchString,
@"v" : @"20130101"
}
success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
DLog(@"Getting favorites return successful update tableview and CD ");
}
failure:^(RKObjectRequestOperation *operation, NSError *error) {
DLog(@"Getting all favorites failed: %@", [error localizedDescription]);
}];
AFネットワーキング =============
AF を使用して呼び出しを行うと、JSON データが完全に返されます。
NSString *searchString = [NSString stringWithFormat:@"%@, %@",[dictionary objectForKey:@"lat"], [dictionary objectForKey:@"lng"]];
AFHTTPClient *client = [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:@"https://api.foursquare.com"]];
NSDictionary *parameters = @{
@"client_id" : kFourSquareClientID,
@"client_secret" : kFourSquareClientSecret,
@"ll" : searchString,
@"v" : @"20130101"
};
NSMutableURLRequest *request = [client requestWithMethod:@"GET" path:@"/v2/venues/search" parameters:parameters];
DLog(@"");
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
NSError *error;
NSDictionary* json = [NSJSONSerialization
JSONObjectWithData:JSON //1
options:kNilOptions
error:&error];
NSLog(@"THIS IS A DICTIONARY (or array): %@", JSON);
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
NSLog(@"if requestFailed");
}];
[operation start];
私の会場オブジェクト ==========
@interface Venue : NSManagedObject
@property (nonatomic, retain) NSString * venueID;
@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) NSString * address;
@property (nonatomic, retain) NSNumber * verified;
@end