iosobjective-ccocoa-touchibeaconnsuuid

I put NSString in NSUUID and I log an wrong UUID iOS


I work with iBeacon and I want to monitor many beacons together. I make a for(NSDictionary *iBeacon in iBeacons) to have all iBeacons I need. In each loop, I try to put NSString into an NSUUID like this :

NSString *uuid = [[NSString alloc] initWithFormat:iBeacon[@"UUID"]];
NSLog(@"UUID = %@",uuid);//first log
NSUUID *proximityUUID = [[NSUUID UUID] initWithUUIDString:uuid];
NSLog(@"proximityUUID = %@",proximityUUID);//Second log

When I look my log I see :

UUID = 5A4BCFCE-174E-4BAC-A814-092E77F6B7E5
proximityUUID = <__NSConcreteUUID 0x16ec5db0> 5A4BCFCE-174E-4BAC-A814-092E77F6B7E5

I would like that UUID equal proximityUUID, I dont understand why <__NSConcreteUUID 0x16ec5db0> is added?

Thank you.


Solution

  • <__NSConcreteUUID 0x16ec5db0> is just some information about the object. It is an instance of __NSConcreteUUID (a concrete subclass of NSUUID) and it's pointer is stored at the memory address 0x16ec5db0. to get the UUID value itself, do

    NSLog(@"proximityUUID = %@",proximityUUID.UUIDString)