简体   繁体   English

类不符合键值编码

[英]Class is not key value coding compliant

I have a NavigationController , root view controller called "ViewController" and a second view controller called "SettingsViewController". 我有一个NavigationController ,根视图控制器称为“ ViewController”,第二个视图控制器称为“ SettingsViewController”。 I have a segue to the "SettingsViewController" from "ViewController" which worked until I tried to connect a UITextField called "usernameField" to the "SettingsViewController" by means of Reference Outlet. 我对“ ViewController”中的“ SettingsViewController”有一个看法,直到我尝试通过参考插座将名为“ usernameField”的UITextField连接到“ SettingsViewController”为止。 When I did I got the following error whenever I try to go to the SettingsViewController: 当我尝试转到SettingsViewController时,遇到以下错误:

*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<_TtC6mayfly22SettingsViewController 0x15e72af0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key usernameField.' ***由于未捕获的异常“ NSUnknownKeyException”而终止应用程序,原因:“ [<_ TtC6mayfly22SettingsViewController 0x15e72af0> setValue:forUndefinedKey:]:此类不适用于密钥usernameField编码的密钥值。”

When I googled the error, most people said that it was caused by a reference outlet that got deleted in code but not in storyboard, or something along those lines, however I have thoroughly checked and have tried remaking the text box numerous times. 当我搜索该错误时,大多数人都说这是由参考插座引起的,该参考插座在代码中被删除,但在情节提要中并未删除,或者是类似的内容,但是我已经进行了彻底检查,并尝试过多次重新构造文本框。 What could I be doing wrong that could be causing this error? 我可能做错了什么可能导致此错误?

Solve this problem by cleaning app and rebuilding it. 通过清洁应用程序并重建它来解决此问题。 Product > Clean or Shift + Command + K 产品>清除或Shift + Command + K

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM