按下按钮时应用程序崩溃

时间:2011-01-07 03:02:00

标签: iphone ios ios4 ipod-touch

首先,我想说我是iPhone开发的新手,而且可能有一件我不知道的事情。

我有一个基于视图的应用程序。我进入了“MainWindow.xib”,并将“Nib Name”更改为“MainMenu”,这是我的应用程序菜单的xib的名称。我有一个按钮,连接到一个动作(showWordChooser),每当按下按钮时,应用程序崩溃。

调试器内容:

2011-01-07 15:56:01.987 NCEAVerbs[20479:207] -[NCEAVerbsViewController showWordChooser]: unrecognized selector sent to instance 0x4b251c0
2011-01-07 15:56:01.990 NCEAVerbs[20479:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NCEAVerbsViewController showWordChooser]: unrecognized selector sent to instance 0x4b251c0'
*** Call stack at first throw:
(
  0   CoreFoundation                      0x00da7be9 __exceptionPreprocess + 185
  1   libobjc.A.dylib                     0x00efc5c2 objc_exception_throw + 47
  2   CoreFoundation                      0x00da96fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
  3   CoreFoundation                      0x00d19366 ___forwarding___ + 966
  4   CoreFoundation                      0x00d18f22 _CF_forwarding_prep_0 + 50
  5   UIKit                               0x00012a6e -[UIApplication sendAction:to:from:forEvent:] + 119
  6   UIKit                               0x000a11b5 -[UIControl sendAction:to:forEvent:] + 67
  7   UIKit                               0x000a3647 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
  8   UIKit                               0x000a21f4 -[UIControl touchesEnded:withEvent:] + 458
  9   UIKit                               0x000370d1 -[UIWindow _sendTouchesForEvent:] + 567
  10  UIKit                               0x0001837a -[UIApplication sendEvent:] + 447
  11  UIKit                               0x0001d732 _UIApplicationHandleEvent + 7576
  12  GraphicsServices                    0x0101ca36 PurpleEventCallback + 1550
  13  CoreFoundation                      0x00d89064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
  14  CoreFoundation                      0x00ce96f7 __CFRunLoopDoSource1 + 215
  15  CoreFoundation                      0x00ce6983 __CFRunLoopRun + 979
  16  CoreFoundation                      0x00ce6240 CFRunLoopRunSpecific + 208
  17  CoreFoundation                      0x00ce6161 CFRunLoopRunInMode + 97
  18  GraphicsServices                    0x0101b268 GSEventRunModal + 217
  19  GraphicsServices                    0x0101b32d GSEventRun + 115
  20  UIKit                               0x0002142e UIApplicationMain + 1160
  21  NCEAVerbs                           0x00001b64 main + 102
  22  NCEAVerbs                           0x00001af5 start + 53
)
terminate called after throwing an instance of 'NSException'
sharedlibrary apply-load-rules all

如果我做bt:

(gdb) bt
#0  0x90a16176 in __kill ()
#1  0x90a16168 in kill$UNIX2003 ()
#2  0x90aa889d in raise ()
#3  0x90abe9bc in abort ()
#4  0x99a16fba in __gnu_cxx::__verbose_terminate_handler ()
#5  0x00efc4e7 in _objc_terminate ()
#6  0x99a1515a in __cxxabiv1::__terminate ()
#7  0x99a1519a in std::terminate ()
#8  0x99a15298 in __cxa_throw ()
#9  0x00efc635 in objc_exception_throw ()
#10 0x00da96fb in -[NSObject(NSObject) doesNotRecognizeSelector:] ()
#11 0x00d19366 in ___forwarding___ ()
#12 0x00d18f22 in __forwarding_prep_0___ ()
#13 0x00012a6e in -[UIApplication sendAction:to:from:forEvent:] ()
#14 0x000a11b5 in -[UIControl sendAction:to:forEvent:] ()
#15 0x000a3647 in -[UIControl(Internal) _sendActionsForEvents:withEvent:] ()
#16 0x000a21f4 in -[UIControl touchesEnded:withEvent:] ()
#17 0x000370d1 in -[UIWindow _sendTouchesForEvent:] ()
#18 0x0001837a in -[UIApplication sendEvent:] ()
#19 0x0001d732 in _UIApplicationHandleEvent ()
#20 0x0101ca36 in PurpleEventCallback ()
#21 0x00d89064 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
#22 0x00ce96f7 in __CFRunLoopDoSource1 ()
#23 0x00ce6983 in __CFRunLoopRun ()
#24 0x00ce6240 in CFRunLoopRunSpecific ()
#25 0x00ce6161 in CFRunLoopRunInMode ()
#26 0x0101b268 in GSEventRunModal ()
#27 0x0101b32d in GSEventRun ()
#28 0x0002142e in UIApplicationMain ()
#29 0x00001b64 in main (argc=1, argv=0xbffff08c) at /Developer/Projects/NCEAVerbs/NCEAVerbs-main.m:13
(gdb) 

我真的不知道发生了什么,请帮忙:)。

2 个答案:

答案 0 :(得分:8)

-[NCEAVerbsViewController showWordChooser]: unrecognized selector sent to instance 0x4b251c0

您显然试图在某个地方拨打showWordChooser,而您所在的地点不存在该地址。

答案 1 :(得分:1)

错误表示您尚未定义方法。检查拼写错误的方法名称,或者将函数放在错误的文件中?