gpt4 book ai didi

iphone - UUID 在 session 中是静态的吗?

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:13:51 26 4
gpt4 key购买 nike

我想使用 UDID 的替代品并找到了这个:

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

但在模拟器中,该方法每次都会给我不同的结果?

这只在模拟器中吗?

我需要确保在实际设备上该方法总是返回相同的字符串识别用户。

这是真的还是假的?

米尔扎

最佳答案

CFUUIDRef 将在每个 session 中创建不同的值。

解决方案一:

将值保存在 NSUserDefaults 中,下次使用 NSUserDefaults 中的值.

解决方案 2:

您可以使用 identifierForVendor 来执行此操作。

NSString *udidVendor = [[[UIDevice currentDevice] identifierForVendor] UUIDString];

根据 UIDevice Class Reference :

The value of this property is the same for apps that come from the same vendor running on the same device. A different value is returned for apps on the same device that come from different vendors, and for apps on different devices regardless of vendor.

请查看Unique Identifier In iOS 6

关于iphone - UUID 在 session 中是静态的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16711584/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com