现在遇到问题。尝试谷歌搜索解决方案,但仍然无法获得任何解决方案。如果有人能帮我解决这个问题,我将不胜感激
基本上我正在使用 AFNetworking 库使用 OneMap API。我得到的返回数据,当我 NSLog 它时, : 被替换为 = 而 [ 被替换为 (
显然,POST 方法不起作用,OneMap 是否只支持 GET?
当我将其转换为字符串并使用 UTF8 对其进行编码时,它会以正确的格式记录,但我无法直接从字符串中检索键值对吗?
这是我用来使用它的代码片段:
-(void)getDrivingDirections:(NSArray *)coords 目的地:(NSArray *)dest {
NSString *destination = [dest componentsJoinedByString:@","];
NSString *currentLocation = [coords componentsJoinedByString:@","];
NSString *routeStops = [[NSString alloc]initWithFormat:@"%@;%@",currentLocation,destination];
NSString *dataURL = [[NSString alloc]initWithFormat:@"http://www.onemap.sg/API/services.svc/route/solve?token=%@&routeStops=%@",tokenString,routeStops];
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:dataURL]];
NSMutableURLRequest *request = [httpClient requestWithMethod:@"GET"
path:dataURL
parameters:nil];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
[httpClient registerHTTPOperationClass:[AFHTTPRequestOperation class]];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"%@",responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
[MMProgressHUD dismissWithSuccess:@"Something went wrong :("];
}];
[operation start];
}
这是返回的片段:http: //pastebin.com/Sa0U0tYf(太长,无法直接在此处发布)
谢谢!