如何在Xcode中调试“无法识别的选择器发送到实例”错误?

时间:2011-04-26 08:44:59

标签: iphone xcode ipad

    2011-04-26 01:36:17.914 Protoype_Test1[15119:207] -[Protoype_Test1ViewController saveImage]: unrecognized selector sent to instance 0x5f60e60
    2011-04-26 01:36:17.933 Protoype_Test1[15119:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Protoype_Test1ViewController saveImage]: unrecognized selector sent to instance 0x5f60e60'
    *** Call stack at first throw:
    (
      0   CoreFoundation                      0x0126cbe9 __exceptionPreprocess + 185
      1   libobjc.A.dylib                     0x010615c2 objc_exception_throw + 47
      2   CoreFoundation                      0x0126e6fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
      3   CoreFoundation                      0x011de366 ___forwarding___ + 966
      4   CoreFoundation                      0x011ddf22 _CF_forwarding_prep_0 + 50
      5   UIKit                               0x00366a6e -[UIApplication sendAction:to:from:forEvent:] + 119
      6   UIKit                               0x003f51b5 -[UIControl sendAction:to:forEvent:] + 67
      7   UIKit                               0x003f7647 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
      8   UIKit                               0x003f61f4 -[UIControl touchesEnded:withEvent:] + 458
      9   UIKit                               0x0038b0d1 -[UIWindow _sendTouchesForEvent:] + 567
      10  UIKit                               0x0036c37a -[UIApplication sendEvent:] + 447
      11  UIKit                               0x00371732 _UIApplicationHandleEvent + 7576
      12  GraphicsServices                    0x01a83a36 PurpleEventCallback + 1550
      13  CoreFoundation                      0x0124e064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
      14  CoreFoundation                      0x011ae6f7 __CFRunLoopDoSource1 + 215
      15  CoreFoundation                      0x011ab983 __CFRunLoopRun + 979
      16  CoreFoundation                      0x011ab240 CFRunLoopRunSpecific + 208
      17  CoreFoundation                      0x011ab161 CFRunLoopRunInMode + 97
      18  GraphicsServices                    0x01a82268 GSEventRunModal + 217
      19  GraphicsServices                    0x01a8232d GSEventRun + 115
      20  UIKit                               0x0037542e UIApplicationMain + 1160
      21  Protoype_Test1                      0x00001c34 main + 102
      22  Protoype_Test1                      0x00001bc5 start + 53
    )
    terminate called after throwing an instance of 'NSException'

2 个答案:

答案 0 :(得分:0)

查看按钮的IBAction是否正确连接。我猜他们没有正确连接

答案 1 :(得分:0)

如果您发布源代码而不是出错,那将会非常有用。

无论如何,我认为你试图通过类引用调用实例方法。 问题出在这里:

[Protoype_Test1ViewController saveImage]

应该是:

[protoype_Test1ViewController saveImage]

在自动完成时,这是一个常见的错误。