NSUnknownKeyException导致按钮单击崩溃

时间:2011-09-29 18:05:58

标签: iphone

所以我不确定发生了什么。我没有太多变化。无论如何都没有与这个课程有任何关系。它之前的工作正常,现在我正在崩溃。

-(IBAction)mphButton:(id)sender{
    if(self.mphVC == nil){
        MphViewController *mph = [[MphViewController alloc] initWithNibName:@"MphView" bundle:[NSBundle mainBundle]];
        self.mphVC = mph;
        [mph release];
    }

    [self.navigationController pushViewController:self.mphVC animated:YES];
}

线程在[self.navigationController pushViewController:self.mphVC animated:YES];

上停止说“线程1:编程接收信号”SIGABRT

这就是消息:

2011-09-29 10:59:03.557 SpeedClock[2973:b303] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<MphViewController 0x4b42ad0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key count.'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x00dc25a9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x00f16313 objc_exception_throw + 44
    2   CoreFoundation                      0x00dc24e1 -[NSException raise] + 17
    3   Foundation                          0x00794677 _NSSetUsingKeyValueSetter + 135
    4   Foundation                          0x007945e5 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
    5   UIKit                               0x0021030c -[UIRuntimeOutletConnection connect] + 112
    6   CoreFoundation                      0x00d388cf -[NSArray makeObjectsPerformSelector:] + 239
    7   UIKit                               0x0020ed23 -[UINib instantiateWithOwner:options:] + 1041
    8   UIKit                               0x00210ab7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
    9   UIKit                               0x000c6628 -[UIViewController _loadViewFromNibNamed:bundle:] + 70
    10  UIKit                               0x000c4134 -[UIViewController loadView] + 120
    11  UIKit                               0x000c400e -[UIViewController view] + 56
    12  UIKit                               0x000c2482 -[UIViewController contentScrollView] + 42
    13  UIKit                               0x000d2f25 -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] + 48
    14  UIKit                               0x000d1555 -[UINavigationController _layoutViewController:] + 43
    15  UIKit                               0x000d2870 -[UINavigationController _startTransition:fromViewController:toViewController:] + 524
    16  UIKit                               0x000cd32a -[UINavigationController _startDeferredTransitionIfNeeded] + 266
    17  UIKit                               0x000d4562 -[UINavigationController pushViewController:transition:forceImmediate:] + 932
    18  UIKit                               0x000cd1c4 -[UINavigationController pushViewController:animated:] + 62
    19  SpeedClock                          0x00002621 -[RootViewController mphButton:] + 353
    20  UIKit                               0x000144fd -[UIApplication sendAction:to:from:forEvent:] + 119
    21  UIKit                               0x000a4799 -[UIControl sendAction:to:forEvent:] + 67
    22  UIKit                               0x000a6c2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
    23  UIKit                               0x000a57d8 -[UIControl touchesEnded:withEvent:] + 458
    24  UIKit                               0x00038ded -[UIWindow _sendTouchesForEvent:] + 567
    25  UIKit                               0x00019c37 -[UIApplication sendEvent:] + 447
    26  UIKit                               0x0001ef2e _UIApplicationHandleEvent + 7576
    27  GraphicsServices                    0x00ffb992 PurpleEventCallback + 1550
    28  CoreFoundation                      0x00da3944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
    29  CoreFoundation                      0x00d03cf7 __CFRunLoopDoSource1 + 215
    30  CoreFoundation                      0x00d00f83 __CFRunLoopRun + 979
    31  CoreFoundation                      0x00d00840 CFRunLoopRunSpecific + 208
    32  CoreFoundation                      0x00d00761 CFRunLoopRunInMode + 97
    33  GraphicsServices                    0x00ffa1c4 GSEventRunModal + 217
    34  GraphicsServices                    0x00ffa289 GSEventRun + 115
    35  UIKit                               0x00022c93 UIApplicationMain + 1160
    36  SpeedClock                          0x00001f59 main + 121
    37  SpeedClock                          0x00001ed5 start + 53
    38  ???                                 0x00000001 0x0 + 1
)
terminate called throwing an exceptionCurrent language:  auto; currently objective-c
(gdb)

我可以在Android上的Logcat上很好地阅读这些内容。只是不要用来阅读这个。我看到另一篇帖子说他们的课程可能与他们的观点无关。我的是。在MPHViewController.m

之前我把一些东西(我推荐它并且它仍然无法工作)之前工作得很好

感谢任何和所有帮助......谢谢:)

1 个答案:

答案 0 :(得分:3)

你很可能在你的“MphView”XIB文件中有一些名为“count”的东西,你在MphViewController中不再拥有它。也许为一个不再存在的对象,或一个动作或类似的东西设置委托。检查Interface Builder中的所有连接,并删除任何损坏的连接。