I have a code to know which beacon is the closest, but I have a problem when a beacon\'s accuracy is -1.00000, the the app takes the second one.
So there is a bucle
locationManager:didRangeBeacons:inRegion:
will return you a list of beacons in proximity order. That is, the first beacon in the list will be the nearest to you.
However, there is one exception to this rule: if any beacons have a proximity of Unknown, then they will be at the top of the list (because their accuracy is -1). To account for this, simply filter out any Unknown beacons, and then pick the first in the list:
beacons = [beacons filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"proximity != %d", CLProximityUnknown]];
CLBeacon *nearestBeacon = [beacons firstObject];