如何删除cllocation的缓存? [英] How to remove cache of cllocation?

查看:123
本文介绍了如何删除cllocation的缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一款支持位置感知应用的iPhone应用。
Currentlly应用程序正常工作,除了以前位置的缓存。
我第一次启动应用程序位置管理器获取当前位置,然后根据当前位置显示附近的东西。



但是从下一次使用它以前获取的位置,直到我重新启动手机,它将获取相同的位置。所以到目前为止,我很清楚位置管理器缓存该位置。



所以我的问题是如何删除此缓存并强制位置管理器获取新位置
谢谢

解决方案

实际上我认为你不能:由你(在你的 CLLocationManagerDelegate 实例中)来过滤这个位置您收到的是基于其时间戳(以确保您处理的职位是最近的职位,而不是缓存职位)。



 



- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
NSDate * eventDate = newLocation.timestamp;
NSTimeInterval howRecent = [eventDate timeIntervalSinceNow];
//活动最新且准确吗?
if(abs(howRecent)< SECS_OLD_MAX){
//使用它!
}
....
....





I am developing an iPhone app which is a location aware app . Currentlly the app is working fine except the caching of previous location . The first time I start the application location manager fetches the current location and then I display nearby things based on the current location .

But from the next it uses previously fetched location and until I restart the phone it will fetch the same location . So up to this point I am clear that the location manager caches the location .

So my question is how to remove this cache and force the location manager to fetch a new location thanks

解决方案

Actually I don't think you can : it's up to you (in your CLLocationManagerDelegate instance) to filter the position you receive based on its timestamp (to ensure that the position you work on is a recent one, not a cached one).

-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{ NSDate *eventDate = newLocation.timestamp; NSTimeInterval howRecent = [eventDate timeIntervalSinceNow]; //Is the event recent and accurate enough ? if (abs(howRecent) < SECS_OLD_MAX) { //WORK WITH IT ! } .... ....

这篇关于如何删除cllocation的缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆