每次我运行这段给Terminating app due to uncaught exception 'NSUnknownKeyException',setValue:forUndefinedKey:]: this class is not key value coding.'的代码,我所做的就是将button连接到label
class ViewController: UIViewController {
@IBOutlet weak var lable: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func button(_ sender: Any) {
lable.text="done"
}
}错误将被引用到class AppDelegate: UIResponder, UIApplicationDelegate
发布于 2017-03-27 03:06:09
转到您的故事板,选择您的ViewController并转到本节

检查一下这里没有任何无效的出口。如果连接一个出口,然后通过代码更改变量的名称,那么xcode仍然会试图找到前一个接口,并会崩溃。
https://stackoverflow.com/questions/43037254
复制相似问题