title: NSMutableDictionary with UIButton* as keys - iPhone development
body: <p>I'm new to iPhone development and I have a question that may have a very simple answer. I am trying to add buttons to a view and these buttons are associated with a custom class that I defined. When I add the buttons to the view, I would like to know what class these buttons correspond to. This is because when I press the button, I need to get some information about the class, but the receiver of the message is another class. I couldn't find information about an error that I'm getting on the web. The problem I have is that I'm trying to create an NSMutableDictionary where the keys are of type UIButton* and the values are of my custom type:</p>
  
  <pre><code>   // create button for unit
     UIButton* unitButton = [[UIButton alloc] init];
     [sourceButtonMap setObject:composite forKey:unitButton];
  </code></pre>
  
  <p>Of course, the sourceButtonMap is defined in the class and initialized in the init function as <code>sourceButtonMap = [[NSMutableDictionary alloc] init];</code></p>
  
  <p>The error I get when I try to add the key-value pair is:</p>
  
  <blockquote>
    <p><code>*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIButton copyWithZone:]: unrecognized selector sent to instance 0x3931e90'</code></p>
  </blockquote>
  
  <p>Is this happening because I can't store UIButton* as keys?
  Can anyone point me why I'm getting this error? Thank you all,</p>
  
  <p>aa</p>