title: custom UIButton, unrecognized selector sent to instance
body: <p>i am trying to subclass a UIButton to attach a property to it, but as you might already guess i get an " unrecognized selector sent to instance" error.</p>
  
  <p>Exact error : [UIButton setAnnotPin:]: unrecognized selector sent to instance </p>
  
  <p>Here is are the important parts of the code:</p>
  
  <p>MapViewController.h:</p>
  
  <pre><code>  #import "UIRightPinAccessoryButton.h"
  </code></pre>
  
  <p>MapViewController.m:</p>
  
  <pre><code>- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id &lt;MKAnnotation&gt;) annotation{ 
   //some other code..
  
  UIRightPinAccessoryButton *rightAccessoryButton = [UIRightPinAccessoryButton buttonWithType:UIButtonTypeDetailDisclosure];
  rightAccessoryButton.frame = CGRectMake(0, 0, 35, 35);
  rightAccessoryButton.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
  rightAccessoryButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
  [rightAccessoryButton addTarget:self action:@selector(rightAccessoryButtonTapped:) forControlEvents:UIControlEventTouchUpInside]; 
  
  rightAccessoryButton.annotPin = annot;  **// Error comes here**
  }
  </code></pre>
  
  <p>and here is my UIRightPinAccessoryButton class:</p>
  
  <p>UIRightPinAccessoryButton.h</p>
  
  <pre><code>#import "Annotations.h"
  
  @interface UIRightPinAccessoryButton : UIButton{
    Annotations *annotPin;
  } 
  
  @property (nonatomic) Annotations *annotPin;
  </code></pre>
  
  <p>UIRightPinAccessoryButton.m</p>
  
  <pre><code>#import "UIRightPinAccessoryButton.h"
  
  @implementation UIRightPinAccessoryButton
  
  @synthesize annotPin;
  
  @end
  </code></pre>
  
  <p>I really don´t understand why xcode is looking for the setAnnotPin: method at UIButton instead of my custom UIRightPinAccessoryButton?? </p>