我正在使用此代码来获取坐标:
_locationManager = [[CLLocationManager alloc] init];
_locationManager.desiredAccuracy = kCLLocationAccuracyBest;
_locationManager.delegate = self;
[_locationManager startUpdatingLocation];
然后我正在使用
- (void)locationManager:(CLLocationManager *)manager
didUpdateLocations:(NSArray *)locations
{
_currentLocation = [locations lastObject];
//Doing some stuff
//I am using stopUpdatingLocation but this delegate is called a lot of times
[_locationManager stopUpdatingLocation];
}
我实际上想获得一次坐标,因为我想避免多次执行 didUpdateLocation 中的代码。我怎样才能做到这一点?