Biribu Biribu - 11 months ago 73
Objective-C Question

NSUUID to NSString

I need to get deviceUUID from a phone in a NSString format.
Now I have this:

NSString *deviceId = [UIDevice currentDevice].identifierForVendor;

Because what I had before, which was:

NSString *deviceId = [UIDevice currentDevice].uniqueIdentifier;

Gives me an error now.

But with the first sentence, I got an alert:

Incompatible pointer types initializing 'NSString *' with an expression of type 'NSUUID *'


As the error tells you, identifierForVendor returns an object of class NSUUID, not a NSString.

If you need a NSString use this:

NSUUID *identifierForVendor = [[UIDevice currentDevice] identifierForVendor];
NSString *deviceId = [identifierForVendor UUIDString];