How to get current geographic points only once in iphone?

I am using the following code in the viewDidLoad method

CLLocationManager *locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; locationManager.distanceFilter = kCLDistanceFilterNone; // whenever we move locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation; [locationManager startUpdatingLocation]; 

Then the method below is called continuously when the location changes.

 - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation 

But I want the current geo-points to be only once. Is there any method that gives you direct current geo-points? I want to calculate the distance between current geographic points and another location when I click the button. please help me if anyone knows.

+6
source share
1 answer

In - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation you can call

 [manager stopUpdatingLocation]; 
+6
source

Source: https://habr.com/ru/post/919040/


All Articles