斯坦福iOS 8计算器应用程序的清除功能

斯坦福iOS 8计算器应用程序的清除功能,ios,swift,model-view-controller,Ios,Swift,Model View Controller,我正在关注斯坦福iOS 8课程,我相信我已经成功地将Clear功能添加到了应用程序中,但我不知道我是否做得很好。我的代码如下: 控制器 模型 我的日志输出是 [8.0] = Optional(8.0) with [] left over [8.0, 9.0] = Optional(9.0) with [8.0] left over [8.0, 9.0, ×] = Optional(72.0) with [] left over [8.0, 9.0, ×, 2.0] = Optional(2.0)

我正在关注斯坦福iOS 8课程,我相信我已经成功地将Clear功能添加到了应用程序中,但我不知道我是否做得很好。我的代码如下:

控制器

模型

我的日志输出是

[8.0] = Optional(8.0) with [] left over
[8.0, 9.0] = Optional(9.0) with [8.0] left over
[8.0, 9.0, ×] = Optional(72.0) with [] left over
[8.0, 9.0, ×, 2.0] = Optional(2.0) with [8.0, 9.0, ×] left over
[8.0, 9.0, ×, 2.0, −] = Optional(70.0) with [] left over
[8.0, 9.0, ×, 2.0, −, 5.0] = Optional(5.0) with [8.0, 9.0, ×, 2.0, −] left over
[8.0, 9.0, ×, 2.0, −, 5.0, ÷] = Optional(14.0) with [] left over
[] = nil with [] left over
我非常确定日志输出中的最后一行是正确的。基本上,我只是希望有更多iOS/MVC经验的人能告诉我是否正确实现了Clear功能。如果我没有,我怎么可能去修复我的代码呢


感谢您在advanced中

我这样做了明确的功能

@IBAction func clear(sender: UIButton) {
    AudioServicesPlaySystemSound(audioSound)
    arrayDigit.removeAll()
    arrayOp.removeAll()
    display.text = "0" //displayStack() // remove !
    displayValue = 0
    equal()
}

你应该把这个问题发布在代码审查部分。很抱歉,我不经常使用这个网站。我该怎么做呢?去代码审查网站,发布同样的问题:
[8.0] = Optional(8.0) with [] left over
[8.0, 9.0] = Optional(9.0) with [8.0] left over
[8.0, 9.0, ×] = Optional(72.0) with [] left over
[8.0, 9.0, ×, 2.0] = Optional(2.0) with [8.0, 9.0, ×] left over
[8.0, 9.0, ×, 2.0, −] = Optional(70.0) with [] left over
[8.0, 9.0, ×, 2.0, −, 5.0] = Optional(5.0) with [8.0, 9.0, ×, 2.0, −] left over
[8.0, 9.0, ×, 2.0, −, 5.0, ÷] = Optional(14.0) with [] left over
[] = nil with [] left over
@IBAction func clear(sender: UIButton) {
    AudioServicesPlaySystemSound(audioSound)
    arrayDigit.removeAll()
    arrayOp.removeAll()
    display.text = "0" //displayStack() // remove !
    displayValue = 0
    equal()
}