title: Programmatically attaching event handlers
body: <p>So, I'm trying to programmatically attach event handlers to widgets I've placed on my iphone application using:</p>
  
  <pre>
  <a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIControl_Class/Reference/Reference.html#//apple_ref/occ/instm/UIControl/addTarget:action:forControlEvents:" rel="nofollow noreferrer">addTarget:action:forControlEvents</a>
  </pre>
  
  <p>I have added a UISegmentedControl in Interface Builder which is exposed through <code>@property seg</code> and in loadView, I have:</p>
  
  <pre>
  - (void)loadView
  {
    [ super loadView ] ;
  
    //k after that attach our own event handlers
    [ seg addTarget:seg action:@selector(sliderEventIB) forControlEvents:UIControlEventAllEvents ];
  }
  </pre>
  
  <p>sliderEventIB, just tells us it feels the event:</p>
  
  <pre>
  -(IBAction)sliderEventIB:(id)sender forEvent:(UIEvent*)event
  {
    puts( "I feel you joanna" ) ;
  }
  </pre>
  
  <p>but the error I'm getting is </p>
  
  <pre>
  ViewControllersTest[6744:207] *** -[UISegmentedControl sliderEventIB]:
  <b>unrecognized selector sent to instance 0x3b21b30</b>
  </pre>
  
  <p>Any idea what it <strong>doesn't</strong> like here?</p>