Xcode все время выдает ошибку: "Unexpectedly found nil while implicitly unwrapping an Optional value" (отметил в коде "Fatal Error")
var plusAndMinus = 0
class ViewController234: UIViewController {
@IBOutlet weak var adam: UILabel!
@IBAction func plus(_ sender: Any) {
plusAndMinus += 1
adam.text = "\(plusAndMinus)"
}
@IBAction func minus(_ sender: Any) {
if(plusAndMinus != 0 ) {
plusAndMinus -= 1
}
adam.text = "\(plusAndMinus)"
}
// Write total amonunt to calculate
@IBOutlet weak var totalAmount: UITextField!
@IBAction func equal(_ sender: Any) {
guard let adamValue = Int(adam.text!), adamValue != 0, // Fatal error
let totalAmountValue = Int(totalAmount.text!) else { return }
let result = totalAmountValue / adamValue
finish.text = String(result)
}
//Show calculated
// finish = totalAmount / adam
@IBOutlet weak var finish: UILabel!
"