iOS的用户界面连接到代码

问题描述:

我每次运行此代码它给Terminating app due to uncaught exception 'NSUnknownKeyException',setValue:forUndefinedKey:]: this class is not key value coding.' 的所有IM做的是连接buttonlabeliOS的用户界面连接到代码

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" 
    } 

} 

错误将被refered到class AppDelegate: UIResponder, UIApplicationDelegate

+0

“我所做的一切都是将按钮连接到标签”。这到底意味着什么? – Adeel

转到你的故事板,选择您的ViewController并转到此部分

enter image description here

检查您是否在此处没有任何无效的Outlet。如果你连接一个插座,然后通过代码更改变量的名称,xcode将会继续尝试找到前一个并且会崩溃。