Luca Luca - 25 days ago 14
iOS Question

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

i try to get the longitude/latitude of the user current location, my code is simply this :

- (void)viewDidLoad {
self.locationManager=[[CLLocationManager alloc]init];
[locationManager setDelegate:self];
[locationManager setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters];
[locationManager startUpdatingLocation];
}

#pragma mark-
#pragma mark CLLocationManagerDelegate
-(void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
float latitude=newLocation.coordinate.latitude;
float longitude=newLocation.coordinate.longitude;
NSLog(@"%f",latitude);
NSLog(@"%f",longitude);
[locationManager stopUpdatingLocation];

}
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
NSLog(@"didFailWithError: %@", error);
}


i got always this error from the
didFailWithError
method :

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


can you please tell me what i miss ? thx in advance :)

MeM MeM
Answer

1) check that you actually have a valid WiFi and 3G connection

if you do then

2) go to settings and reset your location services
3) reset your network settings

this should take care of that issue it is device/network related not app related. Its annoying especially if your app is dependent on location services and the device is WiFi only and people give negative ratings on the Appstore.... pardon me I'm getting a bit emotional there