the warning “'uniqueIdentifier' is depreca

2019-07-04 01:59发布

问题:

I create a new project based on cocos2d-box2d, and there are always 4 warning in two files, one is CLScoreServerPost.m, the code has warning is following

[self addValue:[[UIDevice currentDevice] uniqueIdentifier] key:@"cc_device_id"];

and another is CLScoreServerRequest.m, the code has warning is following

device = [[UIDevice currentDevice] uniqueIdentifier];

both of them show the same warning: 'uniqueIdentifier' is deprecated

so what should I do? many thanks

回答1:

You can use for example OpenUDID https://github.com/ylechelle/OpenUDID

As LearnCocos2D told in a comment there is also a topic on SOF : UIDevice uniqueIdentifier Deprecated - What To Do Now?



回答2:

+(NSString *)GetUUID
{
    CFUUIDRef theUUID = CFUUIDCreate(NULL);
    CFStringRef string = CFUUIDCreateString(NULL, theUUID);
    CFRelease(theUUID);
    return [(NSString *)string autorelease];
}