我试图运行此代码但我继续收到此错误:
致命错误:在展开Optional值时意外发现nil
我不明白这意味着什么或为什么我得到它.任何提示?
import UIKit
class ViewController: UIViewController {
var lastNumber: String = ""
@IBOutlet var answerField: UILabel
@IBOutlet var operaterLabel: UILabel
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func buttonTapped(theButton: UIButton) {
if answerField.text == "0"
{
answerField.text = theButton.titleLabel.text
}
else
{
answerField.text = answerField.text + theButton.titleLabel.text
}
}
@IBAction …Run Code Online (Sandbox Code Playgroud)