前回プロジェクトでコーディングを行ったときにこの問題が発生しましたが、エラーがどこにあるべきかを見つけることができないようです。Mac のブラウザーで URL を試すと、すべて正常に動作し、json ファイルが表示されます。
私のコードは次のとおりです。
NSURL *url = [NSURL URLWithString:@"http://www.overpass-api.de/api/interpreter?data=[out:json];(way(around:150,49.4873181,8.4710548)[\"maxspeed\"];);out body;>;out skel;"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url
cachePolicy:NSURLRequestReloadIgnoringCacheData
timeoutInterval:25];
[request setHTTPMethod: @"POST"];
NSError *requestError;
NSURLResponse *urlResponse = nil;
NSData *response1 = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&requestError];
NSLog(@"%@", response1);
NSLog(@"%@", requestError);
NSString *myString = [[NSString alloc] initWithData:response1 encoding:NSUTF8StringEncoding];
NSLog(@"myString: %@", myString);
私が得ているエラーは次のとおりです。
エラー Domain=NSURLErrorDomain Code=-1002 "サポートされていない URL" UserInfo=0x1706753c0 {NSLocalizedDescription=サポートされていない URL、NSUnderlyingError=0x17044f480 "サポートされていない URL"}
ベスト、ヤコブ