簡短說明病情:無法檢查提交按鈕迅速
我正所謂UserValue
一個值。這將來自一個響應。並且我有一個Confirm
按鈕按下方法。在這種情況下,我每次需要檢查用戶輸入金額是否大於UserValue
的金額。
但是過一段時間的值將是UserValue
將nill.That時間不應該檢查whethere在申請文本中輸入金額大於UserValue
現在,這裏我的代碼:
@IBAction func confirmButnClicked(_ sender: Any) {
print(UserValue)
let Mvalue = Double((UserValue.formattedAmount()))
let stringValue = Int(Mvalue!)
if doubleValue < stringValue {
DialogUtils.showMessageWithOk(controller: self, message: "Maximum Value is : \(UserValue)")
}
}
其工作很好,當我在UserValue
有一些價值,但是當我在這裏得到nill價值的崩潰......我該怎麼處理這個問題:
let stringValue = Int(Mvalue!) // crash here
提前致謝!
條件綁定的初始值設定項必須有可選類型,而不是'String' –
UserValue是可選值嗎?如果不是,則使其成爲可選 – Subramanian
是的,某些時間值將會有一段時間vlaue不會來 –