因此,我正在完成一个教程,并确保我遵循作者的信函,并且我的代码引发了以下错误。
2014-10-01 22:26:14.545 stopwatch2[3503:861733] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<stopwatch2.ViewController 0x7c57f050> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key pause.'
我的问题是:
根据提供的错误,我的申请失败的原因是什么?
这是我无法编译的代码:
import UIKit
class ViewController: UIViewController {
var timer = NSTimer()
@IBOutlet var time : UILabel!
var count = 0
@IBAction func play(sender : AnyObject) {
timer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: Selector("result"), userInfo: nil, repeats: true)
}
@IBAction func pause(sender : AnyObject) {
timer.invalidate()
}
@IBAction func reset(sender : AnyObject) {
timer.invalidate()
count = 0
time.text="0"
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
func result() {
count++
time.text = String(count)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
我真正想知道的是如何自己进行调查,因为我相信其他视频的作者也会产生相同的结果。
视频来自 udemy.com、The Complete iOS8 和 Swift Course..
提前感谢您的帮助。