CLGeocoder reverse geocoding error with Error Domain = NSURLErrorDomain Code = -1000 -

With a CLLocation object (contents, for example, latitude = 48.196169, longitude = 11.620237), I am trying to get the current city and country, for example:

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); } }]; 

basically it works great. But in rare cases, I just get errors:

Error PBRequester with domain Error Error = NSURLErrorDomain Code = -1000 "Ungültige URL" UserInfo = 0x16f5ff30 {NSUnderlyingError = 0x16f57810 "Ungültige URL", NSLocalizedDescription = Ungültige URL}

Tags found: (null), error: Domain Error = kCLErrorDomain Code = 2 "Operation could not be completed. (KCLErrorDomain error 2.)"

I do not know why this is happening.

+6
source share
1 answer

You can use the following code to find the address bar, here you need to pass the latitude and longitude as a parameter

 - (void)findAddress:(CLLocationDegrees)latitude with:(CLLocationDegrees)longitude{ CLLocation *location =[[CLLocation alloc]initWithLatitude:latitude longitude:longitude]; CLGeocoder *geocoder = [[CLGeocoder alloc] init]; [geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) { NSLog(@"Finding address"); if (error) { NSLog(@"Error %@", error.description); } else { NSLog(@"%@",placemarks[0]); } }]; } 

Here you should import the following #import <CoreLocation/CLGeocoder.h>

+1
source

All Articles