【发布时间】:2016-07-02 03:12:48
【问题描述】:
我有这个功能:
func addressToCoordinatesConverter(address: NSString) {
let geoCoder = CLGeocoder()
geoCoder.geocodeAddressString(address, completionHandler: { (placemarks, error) -> Void in
if error = nil {
if placemarks!.count = 0 {
let annotation = MKAnnotation()
annotation.coordinate = (placemark.location?.coordinate)!
self.mapView.showAnnotations([annotation], animated: true)
self.mapView.selectedAnnotations(annotation, animated: true)
}
}
})
我在我的代码中调用它来将地址(字符串“地址”)转换为坐标,然后转换到我的 mapView 上。我在这里的第三行出现错误提示
"NSString is not implicitly convertible to 'String'; did you mean to use 'as' to explicitly convert"
如何才能最好地修复此错误?谢谢
【问题讨论】:
-
按照错误提示。为什么你不在函数中使用 String 呢? func addressToCoordinatesConverter(address: String)