title: Understanding (id)sender
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/5578139/objective-c-what-is-a-id-sender">Objective C: what is a “(id) sender”?</a>  </p>
  </blockquote>
  
  
  
  <p>I have some questions about the following:</p>
  
  <pre><code>- (IBAction)leftButtonPressed:(id)sender 
  {
       UIButton *button = (UIButton*)sender;
       _label.text = button.titleLabel.text;
  }
  </code></pre>
  
  <p>What exactly does <code>(UIButton)*sender</code> do? I mean especially the (UIButton*) with the *. Is it something similar to <code>UIButton *myButton</code> ?</p>
  
  <p>As far as I understand is it some kind of pointer to the button which was pressed, but why is that? And why couldn't I just write</p>
  
  <pre><code>_label.text = sender.titleLabel.text;
  </code></pre>
  
  <p>since it "is" the button? And how do I know what can be send anyway? I mean could I write something like:</p>
  
  <pre><code>-(void)leftButtonPressed:(color)sender {...}
  </code></pre>
  
  <p>in order to pass the color of the button?</p>