小编Ars*_*hia的帖子

致命错误:在展开Optional值时意外发现nil

我试图运行此代码但我继​​续收到此错误:

致命错误:在展开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)

ios swift

17
推荐指数
4
解决办法
6万
查看次数

标签 统计

ios ×1

swift ×1