-3

我的应用中有这部分代码

(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");

}

当我试图构建它时,它给了我关于这一行的错误:

withLabel:[UIDevice currentDevice].uniqueIdentifier

它 是正确的,uniqueidentifier首先在 ios 5 中被弃用

请问我该如何解决?我怎样才能以不同的方式写它,这样就可以了..?

4

1 回答 1

0

使用CFUUID

  • 使用 NSUserdefaults 创建和存储

一些样品

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);
/* ... */
于 2013-07-08T12:05:38.883 回答