gpt4 book ai didi

ios - OSX(还有 iOS): Is there a way to know the cached user GPS locations?

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:43:31 25 4
gpt4 key购买 nike

为了确定用户的位置,我使用了 CoreLocation 框架(我目前正在开发 OSX 应用程序(通过 wifi 确定位置),但我的问题也可能适用于 iOS 应用程序)和以下委托(delegate)方法:

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation

当由于某种原因无法找到用户位置时(例如如果用户的计算机未连接到互联网),将调用以下方法:

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error

在这种情况下,我想获取最后已知的用户位置。我想知道是否有办法获得这个最后已知的位置。某处是否有一系列以前确定的位置?

最佳答案

请引用官方文档:

http://developer.apple.com/library/ios/ipad/#documentation/CoreLocation/Reference/CLLocation_Class/CLLocation/CLLocation.html#//apple_ref/doc/c_ref/CLLocation

据此,

@property(readonly, nonatomic) CLLocation *location

The value of this property is nil if no location data has ever been retrieved. In iOS 4.0 and later, this property may contain a more recent location object at launch time. Specifically, if significant location updates are running and your application is terminated, this property is updated with the most recent location data when your application is relaunched (and you create a new location manager object). This location data may be more recent than the last location event processed by your application.

所以这是获取最后已知位置的唯一方法。如果不为nil,可以使用!

关于ios - OSX(还有 iOS): Is there a way to know the cached user GPS locations?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14081237/

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