user520300
user520300

Reputation: 1527

Deprecated Xcode issues

im getting errors and warnings with the following code:

  1. Warning undeclared selector uniqueIdentifier at the first if statement;
  2. Error Property uniqueIdentifier not found on object of type UIDevice
  3. Error Cast of C pointer type CFStringRef

// Get the users Device Model, Display Name, Unique ID, Token & Version Number

UIDevice *dev = [UIDevice currentDevice];
NSString *deviceUuid;
if ([dev respondsToSelector:@selector(uniqueIdentifier)]) // Warning #1
    deviceUuid = dev.uniqueIdentifier; // Error #1
else {
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    id uuid = [defaults objectForKey:@"deviceUuid"];
    if (uuid)
        deviceUuid = (NSString *)uuid;
    else {
        CFStringRef cfUuid = CFUUIDCreateString(NULL, CFUUIDCreate(NULL));
        deviceUuid = (NSString *)cfUuid; // Error #2
        CFRelease(cfUuid);
        [defaults setObject:deviceUuid forKey:@"deviceUuid"];
    }
}

Upvotes: 0

Views: 1354

Answers (2)

Shamsudheen TK
Shamsudheen TK

Reputation: 31311

UIDevice uniqueIdentifier property is deprecated in iOS 5 and above

    udid = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
    NSLog(@"UDID : %@", udid);

Upvotes: 3

xoail
xoail

Reputation: 3074

  1. You must create a method with name uniqueIdentifier
  2. UIDevice does not have a property called uniqueIdentifier. See this answer.
  3. Look at this answer.

Upvotes: 0

Related Questions