CoreLocation kCLErrorDomain error 5

Nate Symer picture Nate Symer · Jul 18, 2013 · Viewed 12.2k times · Source

I subclassed a CLRegion to support Polygons via overriding containsCoordinate: to use ray casting logic instead of the original distance crunching logic. The subclass is initialized via the normal method (initCircularRegionWithCenter:radius:identifier:), then CLLocationCoordinate2ds are added as NSValues to a mutable array. These coordinates are used during the ray casting logic.

As soon as I try to use the CLRegion subclass, I am confronted with a ton of errors in my application logic, as well as the following error:

2013-07-18 16:46:44.515 Geofencing[4816:907] (identifier 6C11CBAF-3EE4-4257-9D75-9724F4349B5D) <+39.86605072,-75.54420471> radius 186.54m: Error Domain=kCLErrorDomain Code=5 "The operation couldn’t be completed. (kCLErrorDomain error 5.)"

I also tried a different subclass that does not modify any methods but adds a method for reading metadata from an NSDictionary. I was confronted with the same error.

What is going on? Is subclassing CLRegion feasible?

Answer

Nate Symer picture Nate Symer · Jul 19, 2013

I hate to answer my own question, but I have found the solution to my issue. A kCLErrorDomain code/error of 5 denotes that you have tried to monitor more than 20 CLRegions. In my case, both subclasses were guilty of monitoring more than 20 regions.