3

I'm developing an iOS app with reverse geocoding features. When I call the function the first time everything is fine. After the second call (with a new instance of the controller where the call is done) the "Domain=kCLErrorDomain Code=2" Error appears. This happens on the Simulator and on the device. The Coordinates are valid. My Code:

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

}];

Thanks in advance!!

1
  • Did you ever get an answer for this? Commented Jan 7, 2013 at 10:35

2 Answers 2

4

Error 2 usually means that you have called the geolocation server too often. Typically this happens when you send a reverse-Geocoding Request to the server each time the delegate method didUpdateLocations was fired. In the docs Apple says that this should typically only be done once a minute.

1

More info on the this error can be found in Apple's docs on kCLErrorDomain: Core Location Constants Reference and in CLError.h:

kCLErrorNetwork The network was unavailable or a network error occurred.

Not the answer you're looking for? Browse other questions tagged or ask your own question.