An NSUUID is a 128-bit number that is used to uniquely identify objects, types, and other elements. It can be accessed as bytes or is usually used in string form - 68753A44-4D6F-1226-9C60-0050E4C00067. The class includes methods for creating both random UUIDs and instances initialized with a special value.
Bluetooth also uses 128-bit identifiers for features and services. Bluetooth SIG has identified many βwell-knownβ services and features. They are represented as a 16-bit value that combines with the base Bluetooth UUID to get the full 128-bit value.
CBUUID methods know these well-known values ββand can automatically convert 16-bit values ββto their 128-bit equivalent. CBUUID can also be initialized with a 128-bit value if you do not use known values ββ(Ie you created your own private services and characteristics)
For example, initializing a CBUUID with a CBUUID(string:"180F") is ok (this is a battery service), but the NSUUID(string:"180F") will fail because it needs all 128 bits.
When working with Core Bluetooth, you will use CBUUID for services and features. The NSUUID is used for the peripheral identifier, since it is just a MAC with no special meaning.
source share