小编Kha*_*aah的帖子

iOS7应用程序向后兼容iOS5关于唯一标识符

我的应用程序与iOS5和iOS6兼容.到现在为止我使用时没有问题:

NSString DeviceID = [[UIDevice currentDevice] uniqueIdentifier];
Run Code Online (Sandbox Code Playgroud)

现在使用iOS7并且uniqueIdentifier不再工作了,我改为:

NSString DeviceID = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
Run Code Online (Sandbox Code Playgroud)

问题是,这对iOS5不起作用.

如何实现与iOS5的向后兼容?

我试过这个,没有运气:

#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000
    // iOS 6.0 or later
    NSString DeviceID = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
#else
    // iOS 5.X or earlier
    NSString DeviceID = [[UIDevice currentDevice] uniqueIdentifier];
#endif
Run Code Online (Sandbox Code Playgroud)

objective-c uniqueidentifier ios

10
推荐指数
1
解决办法
8740
查看次数

标签 统计

ios ×1

objective-c ×1

uniqueidentifier ×1