Skip to content

Instantly share code, notes, and snippets.

@martennilsson
Created February 9, 2012 08:21
Show Gist options
  • Save martennilsson/1778407 to your computer and use it in GitHub Desktop.
Save martennilsson/1778407 to your computer and use it in GitHub Desktop.
- (void)startStandardUpdates
{
if (nil == locationManager)
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyKilometer;
locationManager.distanceFilter = 10;
[locationManager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
NSDate* eventDate = newLocation.timestamp;
NSTimeInterval howRecent = [eventDate timeIntervalSinceNow];
if (abs(howRecent) < 15.0)
{
NSString *urlString = [NSString stringWithFormat:SERVER_URL, newLocation.coordinate.longitude, newLocation.coordinate.latitude];
NSURL *url = [ NSURL URLWithString:urlString];
NSURLRequest *request = [ NSURLRequest requestWithURL: url ];
[NSURLConnection connectionWithRequest:request delegate:self];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment