0

I have added a tabbarcontroller on window and a button on view respective to first tab. As I run the app and press the button, the app is crashing with this msg:

2011-05-20 18:56:46.258 FeatureList[3395:207] -[UIViewController barButtonPressed:]: unrecognized selector sent to instance 0x4b22520
2011-05-20 18:56:46.262 FeatureList[3395:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController barButtonPressed:]: unrecognized selector sent to instance 0x4b22520'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x00da9be9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x00efe5c2 objc_exception_throw + 47
    2   CoreFoundation                      0x00dab6fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
    3   CoreFoundation                      0x00d1b366 ___forwarding___ + 966
    4   CoreFoundation                      0x00d1af22 _CF_forwarding_prep_0 + 50
    5   UIKit                               0x002b2a6e -[UIApplication sendAction:to:from:forEvent:] + 119
    6   UIKit                               0x003411b5 -[UIControl sendAction:to:forEvent:] + 67
    7   UIKit                               0x00343647 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
    8   UIKit                               0x003421f4 -[UIControl touchesEnded:withEvent:] + 458
    9   UIKit                               0x002d70d1 -[UIWindow _sendTouchesForEvent:] + 567
    10  UIKit                               0x002b837a -[UIApplication sendEvent:] + 447
    11  UIKit                               0x002bd732 _UIApplicationHandleEvent + 7576
    12  GraphicsServices                    0x016dfa36 PurpleEventCallback + 1550
    13  CoreFoundation                      0x00d8b064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
    14  CoreFoundation                      0x00ceb6f7 __CFRunLoopDoSource1 + 215
    15  CoreFoundation                      0x00ce8983 __CFRunLoopRun + 979
    16  CoreFoundation                      0x00ce8240 CFRunLoopRunSpecific + 208
    17  CoreFoundation                      0x00ce8161 CFRunLoopRunInMode + 97
    18  GraphicsServices                    0x016de268 GSEventRunModal + 217
    19  GraphicsServices                    0x016de32d GSEventRun + 115
    20  UIKit                               0x002c142e UIApplicationMain + 1160
    21  FeatureList                         0x000024fc main + 102
    22  FeatureList                         0x0000248d start + 53
    23  ???                                 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
Program received signal:  “SIGABRT”.
kill
quit

The Debugger has exited with status 0.(gdb)

saadnib
  • 11,145
  • 2
  • 33
  • 54
Archana Chaurasia
  • 1,396
  • 3
  • 19
  • 35
  • Possible duplicate of [How can I debug 'unrecognized selector sent to instance' error](https://stackoverflow.com/questions/25853947/how-can-i-debug-unrecognized-selector-sent-to-instance-error) – Cœur Jul 08 '19 at 05:52

4 Answers4

3

This happens when you try to call a method that doesn't exist. It looks like you've set up your button to send a message to the view controller (barButtonPressed:), but you may not have implemented the method if your view controller. Or you may have misspelled the method name or not included the argument in the method implementation.

Post your view controller code.

CharlieMezak
  • 5,999
  • 1
  • 38
  • 54
  • in .h file @interface TodayDeal : UIViewController { NSInteger bTag; } @property(nonatomic,readwrite) NSInteger bTag; -(IBAction)barButtonPressed:(id) sender; @end in .m file @implementation TodayDeal @synthesize bTag; -(IBAction)barButtonPressed:(id) sender { Cities *cv=[[Cities alloc] initWithNibName:nil bundle:nil]; cv.modalTransitionStyle=UIModalTransitionStyleCoverVertical; [self presentModalViewController:cv animated:YES]; [cv release]; } – Archana Chaurasia May 20 '11 at 13:48
  • Geeze. Post the code as an edit to your answer so it's actually readable! – CharlieMezak May 20 '11 at 13:50
  • There's a link at the bottom of your answer that says "edit". Click that. – CharlieMezak May 20 '11 at 13:54
0

This is an old question, but I think I know what happened. Notice how the error message says UIViewController instead of TodayDeal; he needed to change the Xib's file owner from a default UIViewController to TodayDeal

Stephen J
  • 2,367
  • 2
  • 25
  • 31
0

It looks like the button is trying to call barButtonPressed: on the view controller, but that method doesn't exist. Are you sure you don't get warnings during compilation regarding missing methods? My guess is you're not setting the view controller class correctly in a nib file.

Daniel Dickison
  • 21,832
  • 13
  • 69
  • 89
  • All things are ok. Not getting any warning,method also exist, and the view controller class is correct in a nib file otherwise on tapping the there will be any issue but its not… so every thing is fine. – Archana Chaurasia May 20 '11 at 13:42
0

Have you implemented barButtonPressed:? Are you sure you need the colon? Try barButtonPressed as the selector name instead.

nevan king
  • 112,709
  • 45
  • 203
  • 241