这里设置的价格为用户默认(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