出现Terminating app due to uncaught exception 'NSUnknownKeyException', reason: 错误的解决方法

在编译成功但是运行时出现以下错误:

2015-11-19 23:48:27.593 BtnLabelText[1403:85125] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<BtnLabelText.ViewController 0x7f9b204473a0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key clickMe.'
*** First throw call stack:
(
0   CoreFoundation                      0x000000010acdbf45 __exceptionPreprocess + 165
1   libobjc.A.dylib                     0x000000010ca02deb objc_exception_throw + 48
2   CoreFoundation                      0x000000010acdbb89 -[NSException raise] + 9
3   Foundation                          0x000000010b0a5a6b -[NSObject(NSKeyValueCoding) setValue:forKey:] + 288
4   UIKit                               0x000000010b68504c -[UIViewController setValue:forKey:] + 88
5   UIKit                               0x000000010b8b2a71 -[UIRuntimeOutletConnection connect] + 109
6   CoreFoundation                      0x000000010ac1ca80 -[NSArray makeObjectsPerformSelector:] + 224
7   UIKit                               0x000000010b8b1454 -[UINib instantiateWithOwner:options:] + 1864
8   UIKit                               0x000000010b68bc16 -[UIViewController _loadViewFromNibNamed:bundle:] + 381
9   UIKit                               0x000000010b68c542 -[UIViewController loadView] + 178
10  UIKit                               0x000000010b68c8a0 -[UIViewController loadViewIfRequired] + 138
11  UIKit                               0x000000010b68d013 -[UIViewController view] + 27
12  UIKit                               0x000000010b56651c -[UIWindow addRootViewControllerViewIfPossible] + 61
13  UIKit                               0x000000010b566c05 -[UIWindow _setHidden:forced:] + 282
14  UIKit                               0x000000010b5784a5 -[UIWindow makeKeyAndVisible] + 42
15  UIKit                               0x000000010b4f2396 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4131
16  UIKit                               0x000000010b4f89c3 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1750
17  UIKit                               0x000000010b4f5ba3 -[UIApplication workspaceDidEndTransaction:] + 188
18  FrontBoardServices                  0x000000010e8c3784 -[FBSSerialQueue _performNext] + 192
19  FrontBoardServices                  0x000000010e8c3af2 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
20  CoreFoundation                      0x000000010ac08011 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
21  CoreFoundation                      0x000000010abfdf3c __CFRunLoopDoSources0 + 556
22  CoreFoundation                      0x000000010abfd3f3 __CFRunLoopRun + 867
23  CoreFoundation                      0x000000010abfce08 CFRunLoopRunSpecific + 488
24  UIKit                               0x000000010b4f54f5 -[UIApplication _run] + 402
25  UIKit                               0x000000010b4fa30d UIApplicationMain + 171
26  BtnLabelText                        0x000000010aafc51d main + 109
27  libdyld.dylib                       0x000000010d51192d start + 1
28  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException


出现这个的原因是:之前我为按钮添加了一个变量,但是在代码中又把这个变量给删除了,此时关联还在,所以在运行时找这个变量无法找到,所以会出现错误,那么此时就是选择这个变量所在的控件对象右键单击,在弹出的菜单中看是否还存在着关联,如果存在则将此关联删除,删除方法就是单击关联哪里的x号,如下图所示:


删除之后运行正常了


  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值