线程1:创建计时器应用程序时发出Sigabrt信号错误

时间:2015-08-04 20:35:30

标签: ios swift

最近我创建了一个计时器应用程序(非常简单)并且一直在接收错误Thread 1:Signal Sigabrt。控制台消息是

2015-08-04 15:27:09.053 Egg Timer[12332:2557133] *** Terminating app due to
uncaught exception 'NSUnknownKeyException', reason:
'[<Egg_Timer.ViewController      0x7fea60e150e0> setValue:forUndefinedKey:]:
this class is not key value coding-compliant for the key start.'

实际代码是

import UIKit

类ViewController:UIViewController {

var timer = NSTimer()

var time = 0

func incrementTime() {
    time++
    timelabel.text = "\(time)"
}

@IBAction func play(sender: AnyObject) {
    timer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: Selector("incrementTime"), userInfo: nil, repeats: true)
}

@IBAction func pause(sender: AnyObject) {
    timer.invalidate()
}

@IBAction func restart(sender: AnyObject) {
    timer.invalidate()
    time = 0
    timelabel.text = "\(time)"
}

@IBOutlet weak var timelabel: UILabel!

override func viewDidLoad() {
    super.viewDidLoad()


}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

}

1 个答案:

答案 0 :(得分:0)

检查所有IBOutlets。它们是NSUnknownKeyException例外的主要触发器。