1
CLLocation經理協調,一旦我使用這個代碼來獲取座標:獲取與iOS的
_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中的代碼。我怎樣才能做到這一點?