Как заменить uniqueIdentifier на CFUUIDCreate?

Я пытаюсь активировать APNS. Поскольку uniqueIdentifierустарел, я пытаюсь использовать CFUUIDCreateсо следующим кодом:

UIDevice *dev = [UIDevice currentDevice];
NSString *deviceUuid;
if ([dev respondsToSelector:@selector(uniqueIdentifier)])
    deviceUuid = dev.uniqueIdentifier;
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"];
    }
}

How могу ли я заменить uniqueIdentifierна CFUUIDCreate?

10
задан Brad Larson 11 May 2012 в 17:50
поделиться