Possible Duplicate:
Objective C: what is a “(id) sender”?
I have some questions about the following:
- (IBAction)leftButtonPressed:(id)sender
{
UIButton *button = (UIButton*)sender;
_label.text = button.titleLabel.text;
}
What exactly does (UIButton)*sender
do? I mean especially the (UIButton*) with the *. Is it something similar to UIButton *myButton
?
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
_label.text = sender.titleLabel.text;
since it "is" the button? And how do I know what can be send anyway? I mean could I write something like:
-(void)leftButtonPressed:(color)sender {...}
in order to pass the color of the button?