Search code examples
iosobjective-cunrecognized-selector

uncaught exception 'NSInvalidArgumentException' error during runtime


my code is:

- (void)  tableView:(UITableView *)tableView
 commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
  forRowAtIndexPath:(NSIndexPath *)indexPath{
    if (editingStyle == UITableViewCellEditingStyleDelete){
        /* First remove this object from the source */
        [self.allRows removeObjectAtIndex:indexPath.row];

        /* Then remove the associated cell from the Table View */
       [tableView deleteRowsAtIndexPaths:@[indexPath]
                        withRowAnimation:UITableViewRowAnimationFade];

        }
}

i am getting error as follows

2015-02-16 11:57:32.413 SimpleTable[1590:45462] -[ViewController refreshControl]: unrecognized selector sent to instance 0x7fa1d2d936c0
2015-02-16 11:57:32.415 SimpleTable[1590:45462] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ViewController refreshControl]: unrecognized selector sent to instance 0x7fa1d2d936c0'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010d738f35 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010d3d1bb7 objc_exception_throw + 45
    2   CoreFoundation                      0x000000010d74004d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x000000010d69827c ___forwarding___ + 988
    4   CoreFoundation                      0x000000010d697e18 _CF_forwarding_prep_0 + 120
    5   UIKit                               0x000000010db268be -[UIApplication sendAction:to:from:forEvent:] + 75
    6   UIKit                               0x000000010db268be -[UIApplication sendAction:to:from:forEvent:] + 75
    7   UIKit                               0x000000010dc2d410 -[UIControl _sendActionsForEvents:withEvent:] + 467
    8   UIKit                               0x000000010dc2c7df -[UIControl touchesEnded:withEvent:] + 522
    9   UIKit                               0x000000010db6c308 -[UIWindow _sendTouchesForEvent:] + 735
    10  UIKit                               0x000000010db6cc33 -[UIWindow sendEvent:] + 683
    11  UIKit                               0x000000010db399b1 -[UIApplication sendEvent:] + 246
    12  UIKit                               0x000000010db46a7d _UIApplicationHandleEventFromQueueEvent + 17370
    13  UIKit                               0x000000010db22103 _UIApplicationHandleEventQueue + 1961
    14  CoreFoundation                      0x000000010d66e551 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    15  CoreFoundation                      0x000000010d66441d __CFRunLoopDoSources0 + 269
    16  CoreFoundation                      0x000000010d663a54 __CFRunLoopRun + 868
    17  CoreFoundation                      0x000000010d663486 CFRunLoopRunSpecific + 470
    18  GraphicsServices                    0x0000000110d079f0 GSEventRunModal + 161
    19  UIKit                               0x000000010db25420 UIApplicationMain + 1282
    20  SimpleTable                         0x000000010cea27d3 main + 115
    21  libdyld.dylib                       0x000000010fcc8145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

Solution

  • I think your TableView may be getting released after you create it and the method ends. You probably need to create an instance variable inside in View controller that references it.

    @property (strong, nonatomic) IBOutlet UITableView *tablview;
    

    Then remove the associated cell from the Table View

    [self.tablview  deleteRowsAtIndexPaths:@[indexPath]
                            withRowAnimation:UITableViewRowAnimationFade];
    

    May help you..