iOS [ setValue:forUndefineKey:]: this class is not key value coding-compliant

5th,Jan,2016

报错:uncaught exception 'NSUnknownKeyException',reason: '[<NSObject 0x170204110> setValue:forUndefineKey:]: this class is not key value coding-compliant for the key name.

今天在做一个聊天界面小demo,需要从xib文件加载UIView.一开始是新建的ViewController文件自带的xib文件,直接将.h文件中继承的类从UIViewController改成UIView。然后通过[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self)  owner: options 运行报错停在这一句上。

分析:使用[NSBundle mainBundle]loadNibNamed方式加载view文件时,仅适用于只有一个视图且没有任何其他交互绑定

解决方式:在connection inspector中,删除与view的关联,即可。


参考文献:

从Xib文件加载UIView的5种方式,xib加载uiview5种

iOS: setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key name.  



你可能感兴趣的:(iOS [ setValue:forUndefineKey:]: this class is not key value coding-compliant)