App terminating due to uncaught exception NSUnknownKey Exception , key value not coding compliant [duplicate]

最后都变了- 提交于 2020-01-21 19:17:06

问题


Sorry for asking such an easy question, but im a beginner

I was following a tutorial on building apps. I was creating a button, but i accidently named it wrong, i named it instead of when creating the outlet. I named it right though when i created the action. I ran my app and it failed, because my instances called on , not (at least i think thats why my app crashed. So deleted the outlet and and the automatic code xcode writes for the outlet, i remade the outlet and named it right this time. But now when i run my app it terminates, heres the report:

2012-08-21 20:42:07.602 FieldButtonFun[973:c07] * Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key theNutton.' * First throw call stack: (0x14b2022 0xeb2cd6 0x14b1ee1 0x9c3022 0x934f6b 0x934edb 0x94fd50 0x23771a 0x14b3dea 0x141d7f1 0x23626e 0xdc1fc 0xdc779 0xdc99b 0x3b401 0x3b670 0x3b836 0x4272a 0x13596 0x14274 0x23183 0x23c38 0x17634 0x139cef5 0x1486195 0x13eaff2 0x13e98da 0x13e8d84 0x13e8c9b 0x13c65 0x15626 0x271d 0x2685) terminate called throwing an exception

I have no idea what went wrong and i dont understand the error report at all. I thought i already deleted all the automatic code Xcode generated when i created the outlet and remade it. Could anyone help me and find out what could have went wrong?

I could rebuild this app from scratch but i want to understand why this went wrong, for future reference.


回答1:


Xcode cannot find the value for the key theNutton in the class FieldButtonFun.

It's hard to say what's wrong without see the actual code. But in most cases, there could be a bad connection in the XIB file. Please check the XIB, ctrl-click the File's Owner, see if there is any yellow warning.




回答2:


Click on your .xib then you will see the files'Owner on top right click on it and check you have any connection in yellow if you have then please click on cross button(X) and from xib right click and drag connection to filer'owner from your uibutton to make action(method)connection.

Then right click and drag from filer'owner to IBOutlet(the uiobject you declare as IBOutlet in your interface).



来源:https://stackoverflow.com/questions/12065868/app-terminating-due-to-uncaught-exception-nsunknownkey-exception-key-value-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!