gpt4 book ai didi

ios - didUpdateToLocation 调用了两次,好的。为什么oldLocation两次都是nil?

转载 作者:行者123 更新时间:2023-11-29 01:54:26 24 4
gpt4 key购买 nike

我知道在大多数情况下 CLLocationManager 在 init 上被调用了两次,once with cached location data, and once with updated content .

这是有道理的,即使它在两种情况下返回相同的结果(例如:因为模拟位置总是返回相同的坐标和精度)。

这是我的启动过程的日志。 didUpdateToLocation 调用了两次,两次 oldLocation 都是 nil:

// Setup code:
let locationManager = CLLocationManager()
locationManager.delegate = self
locationManager.distanceFilter = 100.0
locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation()

// Log Output:
locationManager didUpdateToLocation
old: nil
new: <+22.28468100,+114.15817700> +/- 5.00m (speed -1.00 mps / course -1.00) @ 6/25/15, 3:21:57 PM Indochina Time

locationManager didUpdateToLocation
old: nil
new: <+22.28468100,+114.15817700> +/- 5.00m (speed -1.00 mps / course -1.00) @ 6/25/15, 3:22:01 PM Indochina Time

没有意义的是 oldLocation 在这些情况下总是 nil。我必须提供一个称为 actualOldLocation 的外部变量来跟踪更新之间的距离变化。我是否做错了什么导致此值为零?

最佳答案

您的目标是什么 iOS? didUpdateToLocation 已从 iOS 6.0 中弃用,不确定它现在是否完全有效。

关于ios - didUpdateToLocation 调用了两次,好的。为什么oldLocation两次都是nil?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31045063/

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