Following your most basic tutorial on monitoring and ranging, i can detect the nearest beacon of an array of beacons with the same uuid. But, once detected, how i discriminate ? I mean, how i identify the beacon? Like, in pseudocode:
"If the beacon region = “Region 1” then…“
"If the beacon major = 1 and the becaon minor = 2 then…”
Maybe this is not a question for here or its’ too basic, in that case, please refer me to some docs? THanks.
When ranging for a UUID, you can differentiate the beacons via their majors and minors. The array passed to the
didRangeBeacons delegate is of the
CLBeacon objects, and each
Thanks for answering!
But, when i say “if (nearestBeacon.minor == 9929) …” , being “nearestbeacon” a CLBeacon object, it gives an error (warning) “Comparison between pointer and integer (‘NSNumber *’ and ‘int’)”
Any examples on the matter?
NSNumber is an object, so if you wanted to compare it to a primitive number (such as
9929), you need to convert it to a primitive number first:
You can read and and learn more about
NSNumber in this tutorial: http://rypress.com/tutorials/objective-c/data-types/nsnumber. It’s a good read, one you should probably go through if you want to learn Objective-C. Distinguishing between objects and primitive types is at the core of programming in Obj-C, so it’ll come in handy many times, I assure you (: