-3

i have this part of code in my app

(void) trackWithCategory:(NSString*)category withAction:(NSString*)action withValue:(float)value
{
    AppController *ac = (AppController*) [UIApplication sharedApplication].delegate;
    BOOL result = [ac.tracker trackEventWithCategory:category
                                          withAction:action
                                           withLabel:[UIDevice currentDevice].uniqueIdentifier
                                           withValue:[NSNumber numberWithInt:(int)(value+0.5)]];
    if (!result)
        NSLog(@"Google Analytics track event failed");

}

and when i'm trying to build it gives me en error about this line:

withLabel:[UIDevice currentDevice].uniqueIdentifier

it rights, uniqueidentifier is deprecated first in ios 5

please how can i fix it ? how can i write it differently so that it will be ok .. ?

Prashant Nikam
  • 2,197
  • 3
  • 15
  • 29
Chief Madog
  • 1,801
  • 4
  • 21
  • 46
  • possible duplicate of [UIDevice uniqueIdentifier Deprecated - What To Do Now?](http://stackoverflow.com/questions/6993325/uidevice-uniqueidentifier-deprecated-what-to-do-now) – thegrinner Jul 08 '13 at 12:07
  • This has been asked loads of times http://stackoverflow.com/questions/7128828/what-can-be-used-with-uidevice-currentdevice and even by myself http://stackoverflow.com/questions/15614903/what-to-do-with-apps-running-on-ios-5-and-below-for-identifierforvender -1 for lack of research – Popeye Jul 08 '13 at 12:23

1 Answers1

0

Use CFUUID

  • Create and store using the NSUserdefaults

some sample

NSString *identifierString = [[NSUserDefaults standardUserDefaults] objectForKey:@"myID"];
if (!identifierString) {
    CFUUIDRef identifier = CFUUIDCreate(NULL);
    identifierString = (NSString*)CFUUIDCreateString(NULL, identifier);
    [[NSUserDefaults standardUserDefaults] setObject:identifierString forKey:@"myID"];
}
NSLog(@"%@",identifierString);
/* ... */
Lithu T.V
  • 19,491
  • 11
  • 53
  • 98