我一直在搜索许多小时,试图迅速找到此关闭问题的解决方案。我已经找到了很多有关解释闭包的资源,但是由于某种原因,我似乎无法正常工作。
这是我要转换为Swift的Objective-C代码:
[direction calculateDirectionsWithCompletionHandler:^(MKDirectionsResponse *response, NSError *error) {
NSLog(@"%@",[response description]);
NSLog(@"%@",[error description]);
}];
和我正在尝试但没有奏效的迅速:
directions.calculateDirectionsWithCompletionHandler(response: MKDirectionsResponse?, error: NSError?) {
println(response.description)
println(error.description)
}
方向是一个MKDirections
对象。
谢谢!
尝试
directions.calculateDirectionsWithCompletionHandler ({
(response: MKDirectionsResponse?, error: NSError?) in
println(response?.description)
println(error?.description)
})
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句