Skip to content

Instantly share code, notes, and snippets.

@kenichi
Created October 15, 2012 18:40
Show Gist options
  • Save kenichi/3894267 to your computer and use it in GitHub Desktop.
Save kenichi/3894267 to your computer and use it in GitHub Desktop.
deprecated CLLocationManager didUpdateToLocation:fromLocation
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
NSMutableArray *locations = [NSMutableArray arrayWithObject:newLocation];
if (oldLocation) [locations insertObject:oldLocation atIndex:0];
[self locationManager:locationManager didUpdateLocations:locations];
}
// --- or the other way around
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
CLLocation *newLocation = [locations objectAtIndex:locations.count - 1];
CLLocation *oldLocation = nil;
if (locations.count > 1)
oldLocation = [locations objectAtIndex:locations.count - 2];
[self locationManager:locationManager didUpdateToLocation:newLocation fromLocation:oldLocation];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment