如何在开发过程中使用identifierForVendor?

编程入门 行业动态 更新时间:2024-10-25 23:35:22
本文介绍了如何在开发过程中使用identifierForVendor?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

Apple建议使用[UIDevice currentDevice] .identifierForVendor。每次在iOS模拟器中运行其应用程序时,此值都会更改。

Apple recommends using [UIDevice currentDevice].identifierForVendor. The value of this changes every time one runs their application within the iOS simulator.

在我的应用程序中的初始功能需要我将设备识别为轻量身份验证的形式。这使得开发乏味,理想情况下,我可以在调试/运行会话中保持一个独特的价值。有没有任何建议,以完成这个?

Initial functionality in my application requires that I recognize the device as a form of light authentication. This makes development tedious, and ideally I could persist a unique value across debug / run sessions. Are there any recommendations for accomplishing this?

推荐答案

这很漂亮清楚地记录了这个值在模拟器中构建和运行时会改变。在实际设备上,只有在用户从其设备中删除您的所有应用并重新安装应用时,该设置才会更改。

It's pretty clearly documented that this value will change when building and running in the simulator. On a real device, it will only change when the user deletes all of your apps from their device and reinstalls the app.

如果您希望模拟器应用使用一致标识符在开发期间可以定义该UUID并仅用于模拟器构建:

If you want the simulator app to use a consistent identifier during development you could define that UUID and use it for simulator builds only:

NSUUID *devId; #if TARGET_IPHONE_SIMULATOR devId = [NSUUID initWithUUIDString:@"SOME-STATIC-UUID-STRING"]; #else devId = [UIDevice currentDevice].identifierForVendor; #endif

请注意,您需要将SOME-STATIC-UUID-STRING真正的UUID字符串。

Note that you need to replace SOME-STATIC-UUID-STRING with a real UUID string.

更多推荐

如何在开发过程中使用identifierForVendor?

本文发布于:2023-07-22 04:06:14,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1184002.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:过程中   如何在   identifierForVendor

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!