[UIDevice currentDevice] 可以使用什么?
[UIDevice currentDevice]
可以包含什么,例如 uniqueIdentifier?谢谢!
What can be with [UIDevice currentDevice]
, such as uniqueIdentifier? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对于 iOS 5,您可以使用以下方法创建一个新的但不是唯一的标识符:
将其保存在文件中并像唯一标识符一样使用它
For iOS 5, you can create a new, but not unique identifier with this:
Save it in a file and use it like unique identifier
与 UIDevice 对象关联的所有属性和方法均在 UIDevice 类参考
要访问唯一标识符,您可以执行以下操作:
All the properties and methods associated with a UIDevice Object are described in the UIDevice Class Reference
To access the Unique Identifer, you can do something like:
因为现在这有点过时了,我只是给出最新的答案。
因为
Apple
认为从iOS 6
开始停止开发者使用[[UIDevice currentDevice] uniqueIdentifier];
是合适的,Suhail Patels< /code> 回答使用建议。他们现在已经开始告诉开发者使用
[[UIDevice currentDevice]identifierForVendor];
,但一些开发者对于是否仍然允许使用uniqueIdentifier
感到困惑,即使他们仍然是否针对iOS 5
及更低版本进行开发。Apple
对此有点挑剔,只是说:来吧,
Apple
给我们提供更多细节。无论如何,由于这背后的混乱,一些开发人员已经开始使用 OpenUDID 来获取唯一标识符。以下是一些有关如何使用它的代码:
编辑
由于
UDID
已被弃用,一些开发人员现在也认为开始使用 MAC 地址是合适的。这是因为 MAC 地址是基于硬件的,因此无法更改。对于那些想要获取 MAC 地址的人来说,苹果在 获取 MAC地址。Because this is slightly out of date now I am just giving an up to date answer.
Because
Apple
has seen fit to stop developers using the[[UIDevice currentDevice] uniqueIdentifier];
fromiOS 6
onwards whichSuhail Patels
answer advices to use. They have now started telling developers to use[[UIDevice currentDevice] identifierForVendor];
, but some developers are confused on whether they are still allowed to useuniqueIdentifier
even if they are still developing foriOS 5
and below or not.Apple
have been a bit fussy about this just saying :Come on
Apple
give us a bit more detail.Anyway because of the confusion behind this some developers have started using OpenUDID to get a unique identifier. Here is some code on how it can be used:
EDIT
Some developers have also now seen fit to start using the MAC Address since
UDID
has been deprecated. This is because the MAC addresses are hardware based and therefore can't be changed. For those of you that which to go for the MAC Address way apple have provided some sample code on Getting MAC Address.