【发布时间】:2014-09-12 01:47:57
【问题描述】:
我只是无法打开 else 块。 xCode 为我提供了“使用 ! 和 ?? 修复它”的选项,遗憾的是这也不能解决问题。
我在 xCode 中收到此错误:
可选类型“字符串?”的值未拆封;你的意思是用!还是??
@IBAction func buttonTapped(theButton: UIButton) {
if answerField.text == "0" {
answerField.text = theButton.titleLabel?.text
} else {
answerField.text = answerField.text + theButton.titleLabel?.text
}
【问题讨论】: