ios - CLPlacemark 没有成员“获取”
问题描述
我指的是一个函数来获取用户的位置,代码如下:
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 has no member 'get'”的内容:
let onePlacemark = placemarks.get(index: 0)
我正在用 swift 4.0 编写项目,并且
import Foundation
import INTULocationManager
已经完成了。
解决方案
推荐阅读
- python-2.7 - 加载嵌套字典
- keras - 如何在 keras 应用程序中修改内置模型
- python - Pywinauto type_keys() 在字符串中省略“%”
- css - 在css中单击时动画li标签
- selenium-webdriver - `Network.loadingFinished` 事件是否在 chrome DevTools 中包含`Network.requestServedFromCache`?
- c++ - 为什么多个 boost::io_services 会阻塞主线程?
- python - 使用 BeauitfulSoup 提取跨度类文本时不返回
- reactjs - 在容器中进行异步调用并分派结果与在动作创建者中进行异步调用
- r - 如何从Countr 包中读取生育数据集?
- node.js - 使用 setupFiles 运行异步代码