0
所以我正在通過一個教程,我已經確保我跟着作者的信,我的代碼會引發以下錯誤。NSUnknownKeyException這個類不是密鑰編碼兼容的密鑰
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,完整iOS8上和斯威夫特場..提前任何幫助
感謝。
謝謝,我會檢查現在併發回... – 2014-10-02 04:35:33
問題解決了,謝謝。我會盡量記住一旦我擁有獎賞就投票。 – 2014-10-02 06:08:19
@ user1664443我可以爲你效勞:-)如果答案適用於你,請記得接受它 – 2014-10-02 06:14:16