MKLocalSearchCompletionHandler completionHandler = ^(MKLocalSearchResponse *response, NSError *error)
{ ... };
如何在swift中转换此完成处理程序?
答案 0 :(得分:0)
以下是一些示例代码:
let localSearchRequest = MKLocalSearchRequest()
localSearchRequest.naturalLanguageQuery = "restaurants"
let localSearch = MKLocalSearch(request: localSearchRequest)
localSearch.startWithCompletionHandler { (localSearchResponse, error) -> Void in
print(localSearchResponse)
}
答案 1 :(得分:0)
以下是与Swift3兼容的示例代码:
let localSearchRequest = MKLocalSearchRequest()
localSearchRequest.naturalLanguageQuery = "restaurants"
let localSearch = MKLocalSearch(request: localSearchRequest)
localSearch.start { (localSearchResponse, error) -> Void in
print(localSearchResponse ?? "no results")
}