大家好,如何为每个长度为15个字符的iphone设备创建唯一标识符?
答案 0 :(得分:0)
通常开发人员使用 CFUUIDRef
CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault);
NSString *uuidString = (NSString *)CFUUIDCreateString(NULL,uuidRef);
CFRelease(uuidRef);
如果你需要15?
您可以剪切此字符串:
NSString *resultString = [uuidString substringWithRange: NSMakeRange (0, 15)];
答案 1 :(得分:-1)
Apple几天前宣布,如果应用程序继续使用旧的已弃用的uniqueidentifier方法,则会被拒绝:
[[UIDevice currentDevice] uniqueIdentifier];
必须更改为:
CFUUIDRef uuid = CFUUIDCreate(NULL);
CFStringRef uuidStr = CFUUIDCreateString(NULL, uuid);
CFRelease(uuid);