【发布时间】:2016-02-09 13:07:40
【问题描述】:
我尝试使用CLGeocoder.reverseGeocodeLocation 从坐标中获取“位置”,但是当执行到达 completionHandler 时,括号内的代码将完全跳到self.currentPlace = (self.place?.locality)! + ", " + (self.place?.thoroughfare)! 冻结应用程序。
我哪里错了??
func updateLocation() {
let location = CLLocation.init(latitude: currentCoordinates.latitude, longitude: currentCoordinates.longitude)
let geocoder = CLGeocoder()
geocoder.reverseGeocodeLocation(location, completionHandler: { (placemarks, error) in
if (error != nil) {
print("Error")
}else {
let pm = placemarks as [CLPlacemark]!
if pm.count > 0 {
self.place = pm.first
self.stopUpdatingLocation()
}
}
})
self.currentPlace = (self.place?.locality)! + ", " + (self.place?.thoroughfare)!
}
【问题讨论】:
标签: swift cllocation completionhandler reversegeocodelocation