-4
我使用下面的代码,却得到了unwrappning斯威夫特意外地发现零而展开的可选值 - 后通过拆我的可选变量
func calculate() -> String {
if let temp1 = self.calculateOther() {
if let temp2 = self.dvalue {
let disAmt = Double(temp1)! * Double(temp2)! //Fails here
let final = disAmt/100
let disStr : String = String(format: "%.02f", final)
return disStr
}
}
return "0.00"
}
阅读“警卫让”。 – Alexander