UITextView Outlet导致未捕获的NSException

时间:2015-11-27 17:52:51

标签: ios nsunknownkeyexception

每当我为UITextField创建一个插座时,它就会破坏我的应用程序。没有构建错误,只是在启动时终止。

"2015-11-27 17:34:19.005 ticTacToe[3540:71629] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ViewController 0x7fbb82682450> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key wins.'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010d8b0c65 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010c003bb7 objc_exception_throw + 45
    2   CoreFoundation                      0x000000010d8b08a9 -[NSException raise] + 9
    3   Foundation                          0x000000010bb99b53 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 259
    4   CoreFoundation                      0x000000010d7f8d50 -[NSArray makeObjectsPerformSelector:] + 224
    5   UIKit                               0x000000010c51d4eb -[UINib instantiateWithOwner:options:] + 1506
    6   UIKit                               0x000000010c3756d8 -[UIViewController _loadViewFromNibNamed:bundle:] + 242
    7   UIKit                               0x000000010c375cc8 -[UIViewController loadView] + 109
    8   UIKit                               0x000000010c375f39 -[UIViewController loadViewIfRequired] + 75
    9   UIKit                               0x000000010c3763ce -[UIViewController view] + 27
    10  UIKit                               0x000000010c291289 -[UIWindow addRootViewControllerViewIfPossible] + 58
    11  UIKit                               0x000000010c29164f -[UIWindow _setHidden:forced:] + 247
    12  UIKit                               0x000000010c29dde1 -[UIWindow makeKeyAndVisible] + 42
    13  UIKit                               0x000000010c241417 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 2732
    14  UIKit                               0x000000010c24419e -[UIApplication _runWithMainScene:transitionContext:completion:] + 1349
    15  UIKit                               0x000000010c243095 -[UIApplication workspaceDidEndTransaction:] + 179
    16  FrontBoardServices                  0x0000000111bc95e5 __31-[FBSSerialQueue performAsync:]_block_invoke_2 + 21
    17  CoreFoundation                      0x000000010d7e441c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
    18  CoreFoundation                      0x000000010d7da165 __CFRunLoopDoBlocks + 341
    19  CoreFoundation                      0x000000010d7d9f25 __CFRunLoopRun + 2389
    20  CoreFoundation                      0x000000010d7d9366 CFRunLoopRunSpecific + 470
    21  UIKit                               0x000000010c242b02 -[UIApplication _run] + 413
    22  UIKit                               0x000000010c2458c0 UIApplicationMain + 1282
    23  ticTacToe                           0x000000010b6f386f main + 111
    24  libdyld.dylib                       0x000000010eaac145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException"

如果可能的话,请在视觉上解释修复,因为我正在编程延迟: - )

1 个答案:

答案 0 :(得分:0)

除了Hayden的答案之外 - 您可以通过查看Xcode中的边距来轻松检查您认为应该连接到View Controller的IBOutlet是否实际上没有连接。如下)。每个IBOutlet都会显示一个填充的圆圈,显示它已连接到故事板上的元素。

如果圆圈是空的,它没有连接,这可能导致崩溃...

enter image description here