2016-09-27 55 views
2

我有迅速2UIDevice.currentDevice()。identifierForVendor!.UUIDString斯威夫特3遷移

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

這無法編譯下面的代碼。我嘗試了xCo​​de中自動修復的建議,並提出了這個建議。

let deviceid = UIDevice.currentDevice.identifierForVendor!.UUIDString 

但是它仍然不能編譯。它說的類型「UUID」值沒有任何成員UUIDString」

+0

爲什麼-1?我認爲這是一個合理的問題,即使它確實有一個簡單的答案。 –

回答

5

我的建議 - 這些類型的問題 - 我們直接進入操場

let deviceid = UIDevice.current.identifierForVendor?.uuidString 

Playground xCode 8

+0

很好用! –