title: custom properties for UIButton (iphone sdk)
body: <p>I have created a subclass for a UIButton and was hoping to pass a custom property to it. However, it's not working and I've since read that subclassing a UIButton isn't a great idea.</p>
  
  <p>MY question is how do I assign a custom property to a button? I am creating a button which is being placed in the headerview of a grouped table. I want to pass to that button the section number. I've done this successfully with a UISwitch in each row, but can't use the same method for the UIButton.</p>
  
  <p>So I create a button</p>
  
  <pre><code>MattsButtonClass *button = [MattsButtonClass buttonWithType:UIButtonTypeCustom];
  button.frame = CGRectMake(240, 15, 45, 30);
  button.MFsectionNo = section; //this would be 1, 2 etc
  //etc
  </code></pre>
  
  <p>So how do I actually do this? you'll see that my UIbutton has a subclass, which looks like this</p>
  
  <pre><code>//.h file
  @interface MattsButtonClass : UIButton {
      int MFsectionNo;
  }
  
  @property (nonatomic) int MFsectionNo;
  
  @end
  
  //.m file
  @implementation MattsButtonClass
  
  @synthesize MFsectionNo;
  
  
  @end
  </code></pre>
  
  <p>The error on the above is</p>
  
  <pre><code>-[UIRoundedRectButton MFsectionNo:]: unrecognized selector sent to instance 0x5673650
  2010-09-07 22:41:39.751 demo4[67445:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIRoundedRectButton MFsectionNo:]: unrecognized selector sent to instance 0x5673650'
  </code></pre>
  
  <p>Is what I am trying not possible? Thanks for any help...</p>