UIDevice.currentDevice()。identifierForVendor!.UUIDString Swift 3迁移

时间:2016-09-27 08:40:11

标签: swift swift2 swift3 ios10 deviceid

我在swift 2中有以下代码

let deviceid = UIDevice.currentDevice().identifierForVendor!.UUIDString

无法编译。我尝试了xCo​​de中自动修复的建议,我想出了这个。

 let deviceid = UIDevice.currentDevice.identifierForVendor!.UUIDString

然而它仍然无法编译。它表示'UUID'类型的值没有成员UUIDString'

1 个答案:

答案 0 :(得分:6)

我的建议 - 针对这些问题 - 直接进入游乐场

let deviceid = UIDevice.current.identifierForVendor?.uuidString

Playground xCode 8