0

I am unable to get my current location on device. It shows first some times correctly but third time it fails and shows this message:

Error while getting core location : (null)

My code is:

CLLocationManager *manager;
manager = [[CLLocationManager alloc] init];
    manager.pausesLocationUpdatesAutomatically=NO;
    manager.delegate = self;//or whatever class you have for managing location
    [manager startUpdatingLocation];

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
    NSLog(@"in update location");
}

- (void)locationManager:(CLLocationManager *)manager
       didFailWithError:(NSError *)error
{
    NSLog(@"Error while getting core location : %@",[error localizedFailureReason]);
}

Output is:

2013-07-03 18:32:33.146 CLLocationUpdate[6084:907] in update location
2013-07-03 18:32:33.200 CLLocationUpdate[6084:907] in update location
2013-07-03 18:32:33.517 CLLocationUpdate[6084:907] in update location
2013-07-03 18:32:34.073 CLLocationUpdate[6084:907] in update location
2013-07-03 18:32:50.903 CLLocationUpdate[6084:907] Error while getting core location : (null)

Help please. Thanks in advance.

shivam
  • 1,148
  • 1
  • 12
  • 28

3 Answers3

0

That kind of error (The operation couldn’t be completed. (kCLErrorDomain error 0.)) can be due to a lot of reasons.

I found a couple of links that talk about the problem, have you checked them?

Location Manager Error : (KCLErrorDomain error 0) didFailWithError: Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error 0.)"

Community
  • 1
  • 1
Antonio MG
  • 20,382
  • 3
  • 43
  • 62
0

From Apple documentation:

Configuration of your location manager object must always occur on a thread with 
an active run loop, such as your application’s main thread.
Omarj
  • 1,151
  • 2
  • 16
  • 43
0

Try to reset the settings of location services, Wifi and network operator. Sometimes it occurs due to invalid settings of resources which provide the location of device.

iDevAmit
  • 1,550
  • 2
  • 21
  • 33