Reputation: 155
i used CLLoction manager to get location.but when ever i start my location then it gives me oldlocation which is store in device previously.i want to reset the location for this i used flag on first launch of application i used newlocation and call stopupdateinglocation and startupdatinglocation method.But oldlocation is not changed it show old location.
Upvotes: 1
Views: 3370
Reputation: 2044
Every CLLocation
has a timestamp
property that you can use to filter all location updates that are too old for your usage.
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
NSTimeInterval age = [newLocation.timestamp timeIntervalSinceNow];
if(age < SOME_CONSTANT_IN_SECONDS)
{
//Use location
}
}
Upvotes: 6
Reputation:
You can't clear the old location, but you can check the horizontalAccuracy to know if this is a good location (current) or something old and irrelevant.
Upvotes: 0