這裏設置的價格爲用戶默認(LoggedInUserSave
是參考UserDefault
):類型轉換成userdefaults INT()在迅速
let currentValue = Int(sender.value)
LblPriceValue.text = "\(currentValue)"
Price = "0," + String(describing: currentValue)
LoggedInUserSave.set(Price, forKey: "PriceFilter")
我需要使用price
值Int
。我使用這個代碼轉換的price
到int
:
p = LoggedInUserSave.value(forKey: "PriceFilter") as! String
Price : Int = Int(p)!
雖然做這件事情讓零值。
對不起,什麼是'價格:INT = INT(P)'!?我甚至無法編譯。 – GreatBigBore
價格只是變量來存儲p的價值 – m123
好,但我在談論這種語法。我不知道它是什麼意思,也不會編譯。如果您發佈了您使用的實際代碼,則可以獲得更好的質量幫助。 – GreatBigBore