逆ジオコーディング機能を備えた iOS アプリを開発しています。初めて関数を呼び出すと、すべて問題ありません。2 回目の呼び出し (呼び出しが行われるコントローラーの新しいインスタンスを使用) の後、「Domain=kCLErrorDomain Code=2」エラーが表示されます。これは、シミュレータとデバイスで発生します。座標は有効です。私のコード:
CLGeocoder *geoCoder = [[CLGeocoder alloc] init];
CLLocation *loc = [[CLLocation alloc] initWithLatitude:cityCoords.latitude longitude:cityCoords.longitude];
self.displayedCity = [[Stadt alloc] init];
[geoCoder reverseGeocodeLocation:loc completionHandler:^(NSArray *placemarks, NSError *error) {
if(!error){
for (CLPlacemark * placemark in placemarks) {
self.displayedCity.name = [placemark locality];
self.displayedCity.stadtCoord = placemark.region.center;
}
[self loadCity:self.displayedCity.name];
}
else{
NSLog(@"failed getting city: %@", [error description]);
}
}];
前もって感謝します!!