title: Programmatically add IBAction to UIButton
body: <p>I am trying to add an action to a UIButton, but keep getting an exception:</p>
  
  <blockquote>
    <p>Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '[UIImageView addTarget:action:forControlEvents:]: unrecognized selector sent to instance 0x595fba0'</p>
  </blockquote>
  
  <p>Here is my code:</p>
  
  <pre><code>- (void)viewDidLoad
  {
      [super viewDidLoad];
  
      UIImage *myIcon = [UIImage imageNamed:@"Icon_Profile"];
      self.profileButton = (UIButton*)[[UIImageView alloc] initWithImage:myIcon];
  
      [self.profileButton addTarget:self action:@selector(profileButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
  
      UIBarButtonItem *buttonItem = [[[UIBarButtonItem alloc] initWithCustomView:profileButton] autorelease];
  
      NSArray *toolbarItems = [[NSArray alloc] initWithObjects:buttonItem, nil];
  
      [self setToolbarItems:toolbarItems animated:NO];
  
      //[toolbarItems release];
      //[profileButton release];
  }
  </code></pre>
  
  <p>Then I have this method in the same View controller:</p>
  
  <pre><code>-(void)profileButtonPressed:(id)sender{
  
  }
  </code></pre>
  
  <p>And in the header I have </p>
  
  <pre><code>-(IBAction)profileButtonPressed:(id)sender;
  </code></pre>
  
  <p>What's going on?</p>