views:

132

answers:

2

Class 1 has the following code that generates the exception -

-(IBAction) searchAllAction: (id) sender {
AddDiagSearchController *search = [[AddDiagSearchController alloc] initWithNibName:@"DiagSearch" bundle:nil];
[self.navigationController pushViewController:search animated:YES];
}

the pushViewController part generates the following exception - 2010-04-14 14:03:31.060 Nav[10314:207] *** -[UIView addTarget:action:forControlEvents:]: unrecognized selector sent to instance 0x3956a80

And the class I'm trying to push has the following code. All the connections for IBOutlets were made through the interface builder. It's has a tableView, search text bar and a tabbar at the bottom and I'll be adding this to a UINavigationController.

@interface AddDiagSearchController : UIViewController <UITableViewDataSource, UITableViewDelegate>{
UIBarButtonItem *quickAdd;
UIBarButtonItem *searchAll;
UITextField *searchTxt;
}

@property (nonatomic, retain) IBOutlet UITextField *searchTxt;
-(IBAction) searchAllClicked:(id) sender;
-(IBAction) quickAddClicked:(id) sender;
-(IBAction) searchBtnClicked;
-(IBAction) resignResponder: (id) sender;
@end

A: 

I'm not sure but it looks like memory-management issue. I found this article on CocoaDev useful in debugging such issues. Note that MallocStackLogging works only on simulator. I would bet that there is issue with previous view or controller (it is released too early), not with pushed one.

By the way it seems that you leak memory for search as you create and don't release nor autorelease it.

iPhone beginner
+1  A: 

That's not an invalid argument exception, it's unrecognized selector. You are sending a message meant for a UIControl to a UIView when pushing your AddDiagSearchController, which implies that you probably have a messed up nib file.

Paul Lynch
Thanks, deleted and recreated the nib file. Works now.
Tejaswi Yerukalapudi