我指的是一个函数来获取用户的位置,并且代码如下:
func updateLocation(_ userLocation: CLLocation) {
if (userLocation.horizontalAccuracy > 0) {
self.locationService.stopUpdatingLocation()
return
}
self.latitude = NSNumber(value: userLocation.coordinate.latitude as Double)
self.longitude = NSNumber(value: userLocation.coordinate.longitude as Double)
if !self.geocoder.isGeocoding {
self.geocoder.reverseGeocodeLocation(userLocation, completionHandler: {(placemarks, error) in
if let error = error {
logger.error("reverse geodcode fail: \(error.localizedDescription)")
return
}
if let placemarks = placemarks, placemarks.count > 0 {
// TODO:
let onePlacemark = placemarks.get(index: 0)
self.address = "\(onePlacemark?.administrativeArea,onePlacemark?.subLocality,onePlacemark?.thoroughfare)"
self.city = (onePlacemark?.administrativeArea!)!
self.street = (onePlacemark?.thoroughfare!)!
}
})
}
}
在构建项目时,它在此行上抛出了“ CLPlacemark没有成员'get'”的内容:
let onePlacemark = placemarks.get(index: 0)
我正在使用Swift 4.0编写项目,并且
import Foundation
import INTULocationManager
完成。