Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove cache of cllocation?

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

like image 375
harshalb Avatar asked Feb 01 '10 10:02

harshalb


1 Answers

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

like image 156
yonel Avatar answered Oct 14 '22 04:10

yonel