How to read button tag in IBAction?

ibaction, objective-c

Solution

Just cast your sender to UIControl

-(IBAction)showDetails:(UIControl *)sender {

    // here I want to NSLOG button tag
    NSLog(@"%d",sender.tag);

}

Problem

I have button: ``` ... UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; [rightButton setTitle:annotation.title forState:UIControlStateNormal]; rightButton.tag = myCustomNumber; [rightButton addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside]; ... ``` And here is IBAction: ``` .. -(IBAction)showDetails:(id)sender{ // here I want to NSLOG button tag } ... ``` How to do that?

Original source