我正在参加 iTunes 大学的课程,名为“使用 Swift 开发 iOS 8 应用程序”。在第三个视频中,我遇到了一个视频中没有出现的问题,即使是相同的代码,如下:
class ViewController: UIViewController{
…
@IBAction func operate(sender: UIButton) {
if userIsInTheMiddleOfTypingANumber{
enter()
}
if let operation = sender.currentTitle {
if let result = brain.performOperation(operation) { > ERROR HERE
displayValue = result
} else {
displayValue = 0
}
}
}
…
}
在阅读了这个错误的许多解释后,我想问题来自这里:
class CalculatorBrain
{
…
func performOperation(symbol: String) {
if let operation = knownOps[symbol] { opStack.append(operation)
}
}
}
如果你能帮助我,谢谢!