0

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"];
    }
}
hypercrypt
  • 15,389
  • 6
  • 48
  • 59
user520300
  • 1,497
  • 5
  • 24
  • 46
  • Unique identifier is depreciated in iOS 7 now... identifierForVendor and advertisingIdentifier are available in ios 7 – Adnan Aftab Jan 15 '14 at 19:35

2 Answers2

3

UIDevice uniqueIdentifier property is deprecated in iOS 5 and above

    udid = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
    NSLog(@"UDID : %@", udid);
Shamsudheen TK
  • 30,739
  • 9
  • 69
  • 102
0
  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.
Community
  • 1
  • 1
xoail
  • 2,978
  • 5
  • 36
  • 70