I have a UIButton, and I want call a method when I click it.
[button addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside]
Meanwhile, I need to pass the tag of UIButton to the click function;
- (void) click : (NSInteger) tag{
NSLog(@"%d tag button clicked",tag);
}
But how can I pass the tag param?
Selectors are the names of messages. They do not carry data. The solution to your problem is as follows: