このコードを使用して座標を取得しています:
_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 でコードを複数回実行することを避けたいので、実際には一度座標を取得したいと考えています。どうやってやるの?