NSInvalidArgumentException

cocoa-touch, iphone

Solution

I had this exact same problem. It's because your ViewController was under a TabBarController and in the View Controller under it, you set the NIB Name to Contact but did not set the Class to Contact in the identity pane.

Problem

Am tearing my hair out here. Have read many examples which describe how to get around this but none have helped me get rid of the problem. Have a simple button on a UIView linked to an IBAction. Code is this... Contact.h ``` #import <UIKit/UIKit.h> @interface Contact : UIViewController { } -(IBAction)buttonPressed:(id)sender; @end ``` Contact.m ``` #import "Contact.h" @implementation Contact - (IBAction)buttonPressed:(id)sender { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Button Pressed" message:@"You pressed the button" delegate:nil cancelButtonTitle:@"Yep, I did." otherButtonTitles:nil]; [alert show]; [alert release]; } ``` Constantly receiving this error message : ``` Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIViewController buttonPressed:]: unrecognized selector sent to instance 0xd1d5f0' ``` Touch Up Inside is linked to the file's owner using buttonPressed. Have downloaded other example code and they work fine. My project and nib are set up identically to the other example code. Haven't got a clue where to even start to try and debug this. Anyone help?

Original source