문제

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top