だから私はチュートリアルを進めており、著者の手紙に従っていることを確認しました。私のコードは次のエラーをスローします。
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 からのものです。
助けてくれてありがとう。