0
所以我在我的代碼中有這個。如何解開可選值?
let hex:String = "#FFFFFF"
var returnValue = UInt()
var newString = String()
newString = hex.replacingOccurrences(of: "#", with: "0x")
returnValue = UInt(newString)! //This line gets an error
它給了我一個解包可選值錯誤。我如何解決它?
斯威夫特3的Xcode版本是8 –
的[什麼是「致命的錯誤可能重複:意外發現零而展開一個可選值「的意思?](http://stackoverflow.com/questions/32170456/what-does-fatal-error-unexpectedly-found-nil-while-unwrapping-an-optional-valu) – Hamish