xib在View上添加了控件就崩溃,莫名的崩溃

具体崩溃如下:

*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<SPSpO2ViewController 0x7f8b0f631c40> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key resultLabel.'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff23e3de6e __exceptionPreprocess + 350
    1   libobjc.A.dylib                     0x00007fff512539b2 objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff23e3da39 -[NSException raise] + 9
    3   Foundation                          0x00007fff258ffbd6 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 325
    4   UIKitCore                           0x00007fff48c722de -[UIViewController setValue:forKey:] + 87
    5   UIKitCore                           0x00007fff48f7f60f -[UIRuntimeOutletConnection connect] + 109
    6   CoreFoundation                      0x00007fff23e2a182 -[NSArray makeObjectsPerformSelector:] + 242
    7   UIKitCore                           0x00007fff48f7c7f8 -[UINib instantiateWithOwner:options:] + 2192
    8   UIKitCore                           0x00007fff48f7d117 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 147
    9   PC100                               0x000000010f905b72 -[SPSpO2ViewController viewDidLayoutSubviews] + 1650
    10  UIKitCore                           0x00007fff4982d80b -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 3013

很莫名其妙的,只要有控件在view上,就会提示找不到

看提示发现,说的是VC上没有这个key.........

什么鬼

解决办法

我的代码我的坑,上图祭天:


image.png

应该是设置View的Custom Class的,给误操作搞成了 Files owner,具体他们的区别,前面文章有提到.

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容