[英]IOS 9 issue : CLGeocoder Network error code 2
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 ;-)) 这里我在IOS 9设备中遇到一个错误(在模拟器中它运行良好;-))
ERROR during geocode: Error Domain=kCLErrorDomain Code=2 "The operation couldn't be completed. (kCLErrorDomain error 2.)" 地理编码期间的错误:错误域= kCLErrorDomain代码= 2“无法完成操作。(kCLErrorDomain错误2.)”
The docs say "you should not send more than one geocoding request per minute". 文档说“你不应该每分钟发送多个地理编码请求”。
kCLErrorNetwork The network was unavailable or a network error occurred. kCLErrorNetwork网络不可用或发生网络错误。
Actually The Code is Working Fine in IOS8
& IOS7
.. its only gives Error
in IOS 9.
实际上代码在IOS8
和IOS7
中IOS8
IOS7
..它只在IOS 9.
给出Error
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: O / P:
Error is (null) 错误是(null)
US 我们
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.