IOS 9问题:CLGeocoder网络错误代码2
我在IOS 9设备中发现了一个错误(在模拟器中工作正常;-) 地理编码期间出错:错误域=kCLErrorDomain代码=2 无法完成操作。(kCLErrorDomain错误2.) 他们说“每分钟不应发送超过一个地理编码请求” kCLErrorNetwork网络不可用或发生网络错误 实际上,代码在IOS 9问题:CLGeocoder网络错误代码2,ios,ios8,cllocationmanager,ios9,geocode,Ios,Ios8,Cllocationmanager,Ios9,Geocode,我在IOS 9设备中发现了一个错误(在模拟器中工作正常;-) 地理编码期间出错:错误域=kCLErrorDomain代码=2 无法完成操作。(kCLErrorDomain错误2.) 他们说“每分钟不应发送超过一个地理编码请求” kCLErrorNetwork网络不可用或发生网络错误 实际上,代码在IOS8和IOS7中运行良好。。它只在IOS 9中给出错误。 它工作得很好 CLLocation *location =[[CLLocation alloc]initWithLatitude:latit
IOS8
和IOS7
中运行良好。。它只在IOS 9中给出错误
。
它工作得很好
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
}
O/p:
- 错误为(空)
- 美国
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);
}
}];