UUID

292 views
Skip to first unread message

svenj...@googlemail.com

unread,
Nov 14, 2013, 5:30:52 PM11/14/13
to easy...@googlegroups.com
Hi everyone,

can someone help me on this? I would like to get a UUID for devices from IOS 5 and later. Who can help me
with the code? Is it correct like this?

UIDevice *dev = [UIDevice currentDevice];
    NSString *deviceUuid;
    if ([dev respondsToSelector:@selector(identifierForVendor)])
        deviceUuid = dev.identifierForVendor.UUIDString;
    else {
        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
        id uuid = [defaults objectForKey:@"deviceUuid"];
        if (uuid)
            deviceUuid = (NSString *)uuid;
        else {
            CFStringRef cfUuid = CFUUIDCreateString(NULL, CFUUIDCreate(NULL));
            deviceUuid = (__bridge NSString *)cfUuid;
            CFRelease(cfUuid);
            [defaults setObject:deviceUuid forKey:@"deviceUuid"];
        }
    }

Reply all
Reply to author
Forward
0 new messages