【发布时间】:2015-10-12 06:43:19
【问题描述】:
我有一个带有视图控制器的地图作为它的委托,我调用下面的方法向地图添加一些自定义引脚并获取到它们的路线。
我想添加路线到引脚的距离,所以我需要计算路线,然后在返回引脚之前添加到自定义引脚的距离。
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
//setup custom pin view and directions request
[directions calculateDirectionsWithCompletionHandler:
^(MKDirectionsResponse *response, NSError *error) {
if (error)
{
// error
} else {
// no error
}
}];
// add distance to custom pin view
// ONLY once directions calculated
return custom pin view;
}
有什么想法可以解决这个问题吗?
【问题讨论】:
标签: multithreading return return-value objective-c-blocks completionhandler