【发布时间】:2012-05-14 17:08:50
【问题描述】:
我正在尝试使用反向地理编码,但该功能没有执行,也不确定为什么..
在这里我附上了我的代码。谢谢你的帮助
//-- reverse geocode, converting from point to address
- (BNRMapPoint *)geocodeLocation:(CLLocation *)location title:(NSString *)title
{
if(!geocoder)
{
geocoder = [[CLGeocoder alloc] init];
}
__block BNRMapPoint * annotation;
[self.geocoder reverseGeocodeLocation:location completionHandler:
^(NSArray * placeMarks, NSError * errors)
{
NSLog(@"in block code");
if([placeMarks count] > 0)
{
NSLog(@"%@", [placeMarks objectAtIndex:0]);
annotation = [[BNRMapPoint alloc] initWithCoordinate:location.coordinate title:title
placeMark:[placeMarks objectAtIndex:0]];
NSLog(@"%@", annotation.placeMark.name);
}
else
{
NSLog(@"failed!!");
}
}];
return annotation;
}
它没有在控制台打印任何东西..所以我认为它没有输入块代码。 但我真的很困惑为什么它没有进入。再次感谢您的帮助
【问题讨论】:
-
这是一个远景,但这可能与 LLDB
NSLog错误有关。尝试在viewDidLoad method中输出一些内容。如果你没有得到输出,看看这个。 NSLog no output in LLDB. Works in GDB -
它在 viewDidLoad 中打印得很好......
标签: ios ios5 geocoding reverse-geocoding