setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key container

我们使用Xib或者Storyboard布局时很多时候会出现以下错误:

setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key container

出现以上错误的原因很多时候因为我们在为控件命名时,由于命名错误,然后按了Ctrl + z撤销或者你直接把这个控件从类中删除。但是xibOutlets中仍然有这个属性和类对应,运行时导致出错。

解决办法:

找到相应的视图文件Xib或者Storyboard选择Show the Connections inspector删除类中不存在的Outlets Connections如下图所示:

setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key container_第1张图片
屏幕快照

你可能感兴趣的:(setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key container)