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

enum CLError : Int {
        case LocationUnknown
        case Denied
        case Network
        case HeadingFailure
        case RegionMonitoringDenied
        case RegionMonitoringFailure
        case RegionMonitoringSetupDelayed
        case RegionMonitoringResponseDelayed
        case GeocodeFoundNoResult
        case GeocodeFoundPartialResult
        case GeocodeCanceled
        case DeferredFailed
        case DeferredNotUpdatingLocation
        case DeferredAccuracyTooLow
        case DeferredDistanceFiltered
        case DeferredCanceled
        case RangingUnavailable
        case RangingFailure
    }

Here i got one Error in IOS 9 Device (in simulator it's working good ;-))

ERROR during geocode: Error Domain=kCLErrorDomain Code=2 "The operation couldn’t be completed. (kCLErrorDomain error 2.)"

Mahmoud Adam
  • 5,772
  • 5
  • 41
  • 62
Mehul
  • 3,033
  • 23
  • 37
  • There is 1 google api which can be one good alternative. Refer my answer here http://stackoverflow.com/a/40670608/2033377 – Deepak Thakur Nov 18 '16 at 10:29

1 Answers1

0

The docs say "you should not send more than one geocoding request per minute".

kCLErrorNetwork The network was unavailable or a network error occurred.

Actually The Code is Working Fine in IOS8 & IOS7.. its only gives Error in IOS 9.

Its Working Perfect.

CLGeocoder *geoCoder = [[CLGeocoder alloc] init];
        [geoCoder cancelGeocode];
        [geoCoder reverseGeocodeLocation:locationManager.location
                       completionHandler:^(NSArray *placemarks, NSError *error)
        {
            NSLog(@"Error is %@",error.localizedDescription);
            for (CLPlacemark *placemark in placemarks) {
                NSLog(@"%@",placemark.ISOcountryCode);
            }
        }];

O/p:

  • Error is (null)

  • US

Mehul
  • 3,033
  • 23
  • 37