Reputation: 119
I want simple get lan,lon valus at the time application start,I dont want to update every second those values as I am changing my possition. I am using this code:
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
[locationManager startUpdatingLocation];
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
latValueNSString = [NSString stringWithFormat: @"%f",newLocation.coordinate.latitude];
lanValueNSString = [NSString stringWithFormat: @"%f",newLocation.coordinate.longitude];
}
But the problem that I cant transfer those values because every millisecond its setting it again and again... how can i set those values only ones and that's it??
Upvotes: 0
Views: 133
Reputation: 747
Call [locationManager stopUpdatingLocation];
once you get a result. You may want to check if the accuracy is what you need before calling stop.
Upvotes: 0
Reputation: 4452
If you only need 1 value, just get the first location and tell the location manager to stop updating the location.
[manager stopUpdatingLocation];
do this when the delegate method is called.
Upvotes: 2