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.