With a CLLocation object (content e.g. latitude = 48.196169, longitude = 11.620237), I try to get the current city and country like:
if(!geocoder) {
geocoder = [[CLGeocoder alloc] init];
}
if (geocoder.geocoding) [geocoder cancelGeocode];
[geocoder reverseGeocodeLocation:lo completionHandler:^(NSArray *placemarks, NSError *error) {
if(devMode) {
NSLog(@"Found placemarks: %@, error: %@", placemarks, error);
}
if (error == nil && [placemarks count] > 0) {
// MY CODE - here placemarks is always (null)
} else {
if(devMode)
NSLog(@"%@", error.debugDescription);
}
}];
mostly, that works great. But in rarely cases, I just get the errors:
PBRequester failed with Error Error Domain=NSURLErrorDomain Code=-1000 "Ungültige URL" UserInfo=0x16f5ff30 {NSUnderlyingError=0x16f57810 "Ungültige URL", NSLocalizedDescription=Ungültige URL}
Found placemarks: (null), error: Error Domain=kCLErrorDomain Code=2 "The operation couldn’t be completed. (kCLErrorDomain error 2.)"
I've absolutely no idea why this happens.