保存按钮单击结果"无法识别的选择器发送到实例"

时间:2015-11-14 01:04:00

标签: ios objective-c uitableview

我没有使用Interface Builder将这个TableViewController添加为新的iOS开发人员,所以可能错过了一些非常简单的观点。当我单击cancel_Clicked按钮时,它正确地解除了视图没有错误,但是当我点击save_Clicked按钮时,我得到以下错误。

我一直在搜索SO并且找不到可能导致此错误的原因的简单解释,但还没有解决它。任何方向都会非常感激。

2015-11-13 17:19:09.763 Quotes[44015:2536500] -[NSIndexPath active]: unrecognized selector sent to instance 0xc000000000000016
2015-11-13 17:19:09.841 Quotes[44015:2536500] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSIndexPath active]: unrecognized selector sent to instance 0xc000000000000016'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010843ef45 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000107eb8deb objc_exception_throw + 48
    2   CoreFoundation                      0x000000010844756d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x0000000108394eea ___forwarding___ + 970
    4   CoreFoundation                      0x0000000108394a98 _CF_forwarding_prep_0 + 120
    5   Quotes                              0x0000000105d364b8 -[SettingsViewController save_Clicked:] + 376
    6   UIKit                               0x000000010678ae91 -[UIApplication sendAction:to:from:forEvent:] + 92
    7   UIKit                               0x0000000106b87393 -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 152
    8   UIKit                               0x000000010678ae91 -[UIApplication sendAction:to:from:forEvent:] + 92
    9   UIKit                               0x00000001068f64d8 -[UIControl sendAction:to:forEvent:] + 67
    10  UIKit                               0x00000001068f67a4 -[UIControl _sendActionsForEvents:withEvent:] + 311
    11  UIKit                               0x00000001068f691f -[UIControl _sendActionsForEvents:withEvent:] + 690
    12  UIKit                               0x00000001068f58d4 -[UIControl touchesEnded:withEvent:] + 601
    13  UIKit                               0x00000001067f8ed1 -[UIWindow _sendTouchesForEvent:] + 835
    14  UIKit                               0x00000001067f9c06 -[UIWindow sendEvent:] + 865
    15  UIKit                               0x00000001067a92fa -[UIApplication sendEvent:] + 263
    16  UIKit                               0x0000000106783abf _UIApplicationHandleEventQueue + 6844
    17  CoreFoundation                      0x000000010836b011 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    18  CoreFoundation                      0x0000000108360f3c __CFRunLoopDoSources0 + 556
    19  CoreFoundation                      0x00000001083603f3 __CFRunLoopRun + 867
    20  CoreFoundation                      0x000000010835fe08 CFRunLoopRunSpecific + 488
    21  GraphicsServices                    0x000000010a013ad2 GSEventRunModal + 161
    22  UIKit                               0x000000010678930d UIApplicationMain + 171
    23  Quotes                              0x0000000105cfbd9f main + 111
    24  libdyld.dylib                       0x00000001088ea92d start + 1
    25  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

这是堆栈跟踪:

-Djava.net.preferIPv4Stack=true

1 个答案:

答案 0 :(得分:1)

我相信你的问题在于这一行:

NSLog(@"Set selected subject %@ to %ld", s.title, (long)s.active);

您正试图在title上致电NSIndexPath。我猜测s实际上是NSIndexPath个对象,而不是Subject个对象。