gpt4 book ai didi

ios - CLLocation 'coordinate' 不可用

转载 作者:行者123 更新时间:2023-11-29 02:36:26 25 4
gpt4 key购买 nike

我在使用 CLLocation 对象获取纬度和经度时遇到问题。

奇怪的是,直到昨天我还能够通过以下方式检索纬度和经度:

func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) {

var location: AnyObject? = locations.last

if let location: AnyObject = location {
//The println illustrates how I would retrieve the lat and long, i.e. by calling
//location.coordinate.latitude.

println(location.coordinate.latitude)

locationDelegate?.updateLabels(location)
self.locationsArray.append(location)
}
}

这现在已经停止工作,并抛出以下编译器错误:

enter image description here

如果我删除 .coordinate 调用并直接在 location 对象上调用 .latitude,它只会返回 nil.我有点不知道这里发生了什么......

如果我 println(location) 我得到以下输出:

<+56.92239472,+1.47020887> +/- 5.00m (speed -1.00 mps / course -1.00) @ 10/11/14, 2:37:59 PM British Summer Time

任何人都可以帮助我了解发生了什么以及如何再次检索纬度和经度吗?

最佳答案

使用func locationManager(manager: CLLocationManager!, didUpdateToLocation newLocation: CLLocation!, fromLocation oldLocation: CLLocation!)代替上面的委托(delegate)方法,然后调用newLocation.cooperative.latitude 似乎有效。

关于ios - CLLocation 'coordinate' 不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26315295/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com