我正在尝试在 Swift 中使用 MKLocalSearch Api。但我无法让它工作。错误来自
var search:MKLocalSearch = MKLocalSearch.init(request)
我阅读了文档,它声明方法名称是 init(request:) 我不确定我做错了什么。请指教。:)
var request = MKLocalSearchRequest()
request.naturalLanguageQuery = searchTextFiled.text
println(searchTextFiled.text)
request.region = self.mapView.region //need to define region later
var search:MKLocalSearch = MKLocalSearch.init(request)
search.startWithCompletionHandler {
(response:MKLocalSearchResponse!, error:NSError!) in
if !error {
var placemarks:NSMutableArray = NSMutableArray()
for item in response.mapItems {
placemarks.addObject(placemarks)
}
self.mapView.removeAnnotations(self.mapView.annotations)
self.mapView.showAnnotations(placemarks, animated: true)
} else {
}
}