QuentindQ
QuentindQ

Reputation: 23

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.

Upvotes: 2

Views: 1388

Answers (2)

Stackia
Stackia

Reputation: 2141

proximityUUID is NSUUID, not NSString.

Instead, you should use UUIDString method.

NSLog(@"proximityUUID = %@", [proximityUUID UUIDString]); //Second log

Upvotes: 1

vikingosegundo
vikingosegundo

Reputation: 52227

<__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) 

Upvotes: 4

Related Questions