这是我的代码和我尝试调用 reverseGeocodeLocation 的完整上下文:
CLLocationCoordinate2D touchMapCoordinate =
[self.mapView convertPoint:touchPoint toCoordinateFromView:self.mapView];
CLLocation *destination = [[CLLocation alloc] initWithLatitude:touchMapCoordinate.latitude longitude:touchMapCoordinate.longitude];
__block CLGeocoder *destinationPin = [[CLGeocoder alloc] init];
__block NSString *destinationPinName;
[destinationPin reverseGeocodeLocation:destination completionHandler:^(NSArray *placemarks, NSError *error) {
if (error){
NSLog(@"Geocode failed with error: %@", error);
return;
}
if(placemarks && placemarks.count > 0)
{
CLPlacemark *topResult = [placemarks objectAtIndex:0];
NSString *addressTxt = [NSString stringWithFormat:@"%@ %@,%@ %@",
[topResult subThoroughfare],[topResult thoroughfare],
[topResult locality], [topResult administrativeArea]];
destinationPinName = [[NSString alloc] initWithString:addressTxt];
}
}];
annotation = [[MQAnnotation alloc] initWithTitle:destinationPinName andCoordinate:touchMapCoordinate];
我在函数入口点、函数的两个 if 块内以及分配注释的函数之后设置了断点。当我到达 reverseGeocodeLocation 块时,destinationPin 具有有效值,但我的程序一直直接跳转到函数调用后设置的断点。任何想法可能会发生什么?