我一直收到错误:
致命错误:在解包可选值时意外发现nil
组合两个动作时。不确定该怎么做,因为我现在只使用Xcode几天了。我想要做的是按下按钮时执行多次计算/操作。先谢谢你的意见!
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var priceTextField: UITextField!
@IBOutlet weak var payoutTextField: UITextField!
@IBOutlet weak var leasingTextField: UITextField!
@IBOutlet weak var payoutLabel: UILabel!
@IBOutlet weak var leasingsumLabel: UILabel!
@IBOutlet weak var restsumLabel: UILabel!
@IBAction func loanCalculate(_ sender: Any) {
let price: Double = Double(priceTextField.text!)!
let twentyPercentOfPrice: Double = price * 0.2
payoutLabel.text = String(twentyPercentOfPrice)
let leasingsum: Double = Double(leasingTextField.text!)!
let thirtyPercentOfLeasing: Double = leasingsum * 0.3
leasingsumLabel.text = String(thirtyPercentOfLeasing)
}
}