我在我的应用中有这部分代码
(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
它的权利,
首先在ios 5中弃用uniqueidentifier
请 我该怎么办呢? 我怎么能以不同的方式写它以便它可以......?
答案 0 :(得分:0)
一些样本
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);
/* ... */