Alex
Alex

Reputation: 3072

didUpdateToLocation never called

I am using both the simulator and my device to test this, but no matter what I do, didUpdateToLocation is never called. I have tried changing my location in the sim, turning off and then on again my location services on my phone to force the phone to search for a new location... nothing. In my viewDidLoad(), I have started the CLLocationManager as so:

CLLocationManager *manager = [[CLLocationManager alloc] init];

if (![CLLocationManager locationServicesEnabled])    
{
    UIAlertView *servicesDisabledAlert = [[UIAlertView alloc] initWithTitle:@"Location Services Disabled" message:@"You currently have all location services for this device disabled. If you proceed, you will be asked to confirm whether location services should be reenabled." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [servicesDisabledAlert show];

} else {
    manager.desiredAccuracy = kCLLocationAccuracyBest;

    manager.delegate = self;

    [manager startUpdatingLocation];


}

and in the update location method I have this:

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

NSLog(@"NEW LOCATION! Accuracy:[%f]",newLocation.horizontalAccuracy);

}

Does anyone have any ideas why this isn't being called?

Upvotes: 0

Views: 2878

Answers (2)

Semere Taézaz Sium
Semere Taézaz Sium

Reputation: 4036

I don't know if this is the issue but try

manager.desiredAccuracy = kCLLocationAccuracyKilometer;      

or

manager.desiredAccuracy = kCLLocationAccuracyTenMeters; 

instead of

manager.desiredAccuracy = kCLLocationAccuracyBest;

and see if that makes any change.

Setting desiredAccuracy to best timed out most of the times when I test my location dependent apps on my iPhone. Especially when you are indoors.

Upvotes: 1

AAV
AAV

Reputation: 3803

Did you add location delegate in your header file ?

Upvotes: 2

Related Questions