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
}
这里我在IOS9设备上遇到了一个错误(模拟器上它工作得很好;-))
地理编码期间出现错误:Error Domain=kCLErrorDomain Code=2 "无法完成操作。(kCLErrorDomain错误2。)"