title: IOS 5.1 ARC Unrecognized Selector Sent to Instance
body: <p>I have been looking at similar question but couldn't figure it out what is the problem.It seems it should work but it gives me error. </p>
  
  <p>In IOS 5.1 Ipad Stortyboard application I have a right navigation bar item when user click a popover view should open. I had a working popover view but design was not good so I replaced it with a new popover class now it gives me following error</p>
  
  <pre><code>-[UIButton view]: unrecognized selector sent to instance 0xa17ba80
  *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIButton view]: unrecognized selector sent to instance 0xa17ba80'
  </code></pre>
  
  <p>I have tried following functions but none has worked so far. It gives me similar errors when I change the code.</p>
  
  <pre><code>- (IBAction)setColorButtonTapped:(id)sender{
  - (void)setColorButtonTapped:(id)sender{
  - (IBAction)setColorButtonTapped:(id)sender forEvent:(UIEvent*)event {
  - (void)setColorButtonTapped:(id)sender forEvent:(UIEvent*)event {
  </code></pre>
  
  <p>and ofcourse I have changed ti following regarding to <strong>ibaction</strong> or <strong>void</strong></p>
  
  <pre><code>[backButton2 addTarget:self action:@selector(setColorButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
  </code></pre>
  
  <p>here is the code
  my.h file </p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  #import "ColorPickerController.h"
  
  @interface MeetingViewController : UITableViewController&lt;UIApplicationDelegate,UIAlertViewDelegate,DropDownListDelegate,MFMailComposeViewControllerDelegate,EGORefreshTableHeaderDelegate,ColorPickerDelegate&gt;{
  
      UIPopoverController *_popover;
      ColorPickerController *_colorPicker;
      UIPopoverController *_colorPickerPopover;
  
  }
  @property (nonatomic, strong) UIPopoverController *popover;
  @property (nonatomic, strong) ColorPickerController *colorPicker;
  @property (nonatomic, strong) UIPopoverController *colorPickerPopover;
  
  - (IBAction)setColorButtonTapped:(id)sender;
  @end
  </code></pre>
  
  <p>my.m file </p>
  
  <pre><code>@synthesize popover = _popover;
  @synthesize colorPicker = _colorPicker;
  @synthesize colorPickerPopover = _colorPickerPopover;
  
  - (void)viewDidLoad 
  {
      [super viewDidLoad];
      //gear button on navigation Bar
      UIImage* imageback2 = [UIImage imageNamed:@"ICON - Gear@2x.png"];
      CGRect frameimgback2 = CGRectMake(0, 0, 40, 40);
  
      UIButton *backButton2 = [[UIButton alloc] initWithFrame:frameimgback2];
      [backButton2 setBackgroundImage:imageback2 forState:UIControlStateNormal];
      [backButton2 addTarget:self
                      action:@selector(setColorButtonTapped:)
            forControlEvents:UIControlEventTouchUpInside];
  
      UIBarButtonItem *btn2 = [[UIBarButtonItem alloc] initWithCustomView:backButton2];
      self.navigationItem.rightBarButtonItem = btn2;
  
  }
  #pragma mark ColorPickerDelegate
  
  - (void)colorSelected:(NSString *)color {
  
      [self.colorPickerPopover dismissPopoverAnimated:YES];
  }
  
  #pragma mark Callbacks
  
  - (IBAction)setColorButtonTapped:(id)sender {
      if (_colorPicker == nil) {
          self.colorPicker = [[ColorPickerController alloc] initWithStyle:UITableViewStylePlain];
          _colorPicker.delegate = self;
          self.colorPickerPopover = [[UIPopoverController alloc] initWithContentViewController:_colorPicker];
      }
      [self.colorPickerPopover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
  }
  </code></pre>
  
  <p>utility class
  ColorPickerController.h</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  @protocol ColorPickerDelegate
  - (void)colorSelected:(NSString *)color;
  @end
  
  
  @interface ColorPickerController : UITableViewController {
      NSMutableArray *_colors;
      id&lt;ColorPickerDelegate&gt; __weak _delegate;
  }
  
  @property (nonatomic, strong) NSMutableArray *colors;
  @property (nonatomic, weak) id&lt;ColorPickerDelegate&gt; delegate;
  
  @end
  </code></pre>
  
  <p>utilityclass
  ColorPickerController.m</p>
  
  <pre><code>#import "ColorPickerController.h"
  
  
  @implementation ColorPickerController
  @synthesize colors = _colors;
  @synthesize delegate = _delegate;
  
  #pragma mark -
  #pragma mark Initialization
  
  /*
  - (id)initWithStyle:(UITableViewStyle)style {
      // Override initWithStyle: if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
      if ((self = [super initWithStyle:style])) {
      }
      return self;
  }
  */
  
  
  #pragma mark -
  #pragma mark View lifecycle
  
  
  - (void)viewDidLoad {
      [super viewDidLoad];
      self.clearsSelectionOnViewWillAppear = NO;
      self.contentSizeForViewInPopover = CGSizeMake(150.0, 140.0);
      self.colors = [NSMutableArray array];
      [_colors addObject:@"Red"];
      [_colors addObject:@"Green"];
      [_colors addObject:@"Blue"];
  }
  
  
  
  
  - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
      // Override to allow orientations other than the default portrait orientation.
      return YES;
  }
  
  
  #pragma mark -
  #pragma mark Table view data source
  
  - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
      // Return the number of sections.
      return 1;
  }
  
  
  - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
      // Return the number of rows in the section.
      return [_colors count];
  }
  
  
  // Customize the appearance of table view cells.
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  
      static NSString *CellIdentifier = @"Cell";
  
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
      if (cell == nil) {
          cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
      }
  
      // Configure the cell...
      NSString *color = [_colors objectAtIndex:indexPath.row];
      cell.textLabel.text = color;
  
      return cell;
  }
  
  
  
  
  #pragma mark -
  #pragma mark Table view delegate
  
  - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
      if (_delegate != nil) {
          NSString *color = [_colors objectAtIndex:indexPath.row];
          [_delegate colorSelected:color];
      }
  }
  
  
  #pragma mark -
  #pragma mark Memory management
  
  - (void)didReceiveMemoryWarning {
      // Releases the view if it doesn't have a superview.
      [super didReceiveMemoryWarning];
  
      // Relinquish ownership any cached data, images, etc that aren't in use.
  }
  
  - (void)viewDidUnload {
      // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
      // For example: self.myOutlet = nil;
  }
  
  
  - (void)dealloc {
      self.delegate = nil;
  }
  
  @end
  </code></pre>
  
  <p>Help is much appreciated , thanks</p>