現在問題が発生しています。解決策をグーグルで調べてみましたが、まだ何も得られません。誰かがこれで私を助けることができれば本当に感謝します
基本的に、AFNetworking ライブラリを使用して OneMap API を使用しています。取得した戻りデータは、NSLog を実行すると、: が = に置き換えられ、[ が ( に置き換えられます。
どうやら、POST アプローチは機能しません。OneMap は GET のみをサポートしていますか?
文字列に変換して UTF8 でエンコードすると、適切な形式でログに記録されますが、文字列から直接キー値を取得できませんか?
これは、私がそれを消費するために使用しているコードのスニペットです:
-(void)getDrivingDirections:(NSArray *)coords destination:(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 (ここに直接投稿するには長すぎます)
ありがとう!