AMI amitekh AMI amitekh - 9 days ago 4x
Objective-C Question

How to pass two arguments to a UIButtons target method in iOS?

In my code I've to pass two arguments to targetMethod

, I can pass the button.tag as one argument and how to pass the other argument?

Please Give an Example.

My code:

button.tag = indexPath.row;
secondArgument = indexPath.section;
[button addTarget:self action:@selector(printMethod:) forControlEvents:UIControlEventTouchUpInside];



If you want the indexPath on button action then try something like this.


     CGPoint point = [sender.superview toView:self.tableView];
     NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:point];
     if (indexPath) {
          NSLog(@"Section - %ld Row - %ld",deleteIndexPath.section, deleteIndexPath.row);