What is sent as an sender to IBAction?

When I use the code -(IBAction) onClick1: (id) sender;, what will be transmitted as sender? I tried using the sender as the identifier of the object and failed (I mean, I used the code sender.tagand it didn’t return).

I am sure that when I use - (void)buttonTouched1:(UIButton *)sender;here the sender should act as an identifier for the object.

+3
source share
2 answers

Usually a variable senderis an object that sent an action message (this is not exactly guaranteed), for example, you can send an action message yourself and pass everything you want, but how it should work).

sender.tag , , , , . [sender tag], .

+4

, onClick1. , , - (IBAction) onClick1: (id) " " , , , , , to onClick1:

-(IBAction)onClick1:(id)sender
{
   UIButton *button = (UIButton*)sender;
   NSLog(@"%@", button);
}
+6

Source: https://habr.com/ru/post/1774879/


All Articles