Biribu Biribu - 1 year ago 129
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 *'

Answer Source

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];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download