关于出现this class is not key value coding-compliant for the key的错误

关于出现this class is not key value coding-compliant for the key的错误


        随着应用里的viewcontroller及其中的控件数量越来越多,有的时候报出个莫名其妙的错误都不知道该如何着手去排错,比如我遇到的这个错误:


*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<XXXXXXXXXXX 0x000000> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key *


         网上的答案也已经很齐全了,我就不献丑了,原因就是某个控件以前连接到了某个ViewController中的变量,但是因为某些原因,这个连接丢失了,但是连接的这个变量还在,由此造成了这个问题。

        要排错也很简单,找到可疑的.h文件,看里面有没有丢失连接的变量,如图:关于出现this class is not key value coding-compliant for the key的错误

        图中的变量tackIt就是造成这个错误的罪魁祸首,删除之或者重新建立连接即可解决问题。

        仅供新手参考,望指正。