Reputation: 1427
I am using following code in viewDidLoad method
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone; // whenever we move
locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
[locationManager startUpdatingLocation];
Then below method is called continuously when location changed.
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
But I want current geo points only once. Is there any method which gives you directly current geo points? I want to calculate distance between current geo points and other location when I click some button. please help me if any one knows.
Upvotes: 6
Views: 2726
Reputation: 9098
In - (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
you can call
[manager stopUpdatingLocation];
Upvotes: 6