Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CLLocationManager kCLErrorDomain Codes?

Using iBeacon and CoreLocation I'm receiving the following error:

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

Unless I'm missing it, there doesn't seem to be a clear reference on Apple for what each of the error code means.

Can anyone interpret this error code?

The error calls from:

- (void)locationManager:(CLLocationManager *)manager rangingBeaconsDidFailForRegion:    (CLBeaconRegion *)region withError:(NSError *)error{
NSLog(@"%@", error);
}

- (void)locationManager:(CLLocationManager *)manager monitoringDidFailForRegion:(CLRegion *)region withError:(NSError *)error{
NSLog(@"%@", error); }
like image 713
BEEKn Avatar asked Nov 23 '13 16:11

BEEKn


2 Answers

Look at the docs for CLError. Value 16 is kCLErrorRangingUnavailable.

The docs say:

Ranging is disabled. This might happen if the device is in Airplane mode or if Bluetooth or location services are disabled.

like image 162
rmaddy Avatar answered Oct 05 '22 05:10

rmaddy


You can use the CLError enum and the error returned to your location manager to handle location errors in a specific and clear way.

It looks like this:

func locationManager(manager: CLLocationManager!, didFailWithError error: NSError!) {
  if let locationError = CLError(rawValue: error.code) {
    switch locationError {
    case .Denied:
      println("Location permissions denied")
    default:
      println("Unhandled error with location: \(error)")
    }
  }
}

Thanks to @rmaddy for the CLError tip.

like image 20
SimplGy Avatar answered Oct 05 '22 06:10

SimplGy