出现如下异常导致闪退:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle:
'NSBundle </Users/idev/Library/Developer/CoreSimulator/Devices/4A5418B1-CE9E-4B56-8AF4-97D3A9C8187E/data/Containers/Bundle/Application/80855556-1287-43C3-9636-0BA1DCC480B1/test.app> (loaded)' with name 'tableViewCell''
出现这种问题的原因是:
- [nibWithNibName:xxxx bundle:nil]中的xib的名称xxxx错误;
- 在Xcode外部(如在Finder中修改了)修改了XIB文件的名称;
一般第一种情况检查下名称,然后修改为正常的名称即可。
第二种,需要将tableViewCell.xib文件右击 - Delete - Remove Reference
移除引用,然后重新导入即可(重新将Finder中的文件拖入Xcode中,这时project文件就会发生改变,即添加了其reference)。
重新运行程序后又出现了如下错误:
Unknown class tableViewCell in Interface Builder file.
2018-12-05 15:48:07.578927+0800 test[20719:683015] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UITableViewCell 0x7ffcbf18a600> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key EditValue.'
这是因为xib对应的class类的名称也在外部修改了,所以重复上面的操作即可。