I keep getting the error:
Fatal error: Unexpectedly found nil while unwrapping an Optional value
when combining two actions. Not exactly sure what to do, since I have been using Xcode only for a few days now. What I would like to do is to perform several calculations/actions when the button is pressed. Thanks beforehand for the input!
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)
}
}