How to remove cache of cllocation?

2019-03-31 05:20发布

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

1条回答
该账号已被封号
2楼-- · 2019-03-31 05:50

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 ! } .... ....

查看更多
登录 后发表回答