【发布时间】:2014-03-19 16:42:10
【问题描述】:
使用 CLLocation 对象(内容例如纬度 = 48.196169,经度 = 11.620237),我尝试获取当前城市和国家/地区,例如:
if(!geocoder) {
geocoder = [[CLGeocoder alloc] init];
}
if (geocoder.geocoding) [geocoder cancelGeocode];
[geocoder reverseGeocodeLocation:lo completionHandler:^(NSArray *placemarks, NSError *error) {
if(devMode) {
NSLog(@"Found placemarks: %@, error: %@", placemarks, error);
}
if (error == nil && [placemarks count] > 0) {
// MY CODE - here placemarks is always (null)
} else {
if(devMode)
NSLog(@"%@", error.debugDescription);
}
}];
大多数情况下,效果很好。但在极少数情况下,我只会收到错误消息:
PBRequester 失败,错误域=NSURLErrorDomain 代码=-1000 “Ungültige URL”用户信息=0x16f5ff30 {NSUnderlyingError=0x16f57810 "Ungültige URL", NSLocalizedDescription=Ungültige URL}
找到地标:(null),错误:Error Domain=kCLErrorDomain Code=2 "操作无法完成。(kCLErrorDomain error 2.)"
我完全不知道为什么会发生这种情况。
【问题讨论】:
标签: ios7 xcode5 cllocation clgeocoder