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); }
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With