How can I pass an argument in the @selector
for my code below?
[thisIconBtn addTarget:self action:@selector(changeIconState) forControlEvents:UIControlEventTouchUpInside];
-(void)changeIconState:(UITableViewCell*)thisCell
{
//do something
}
First, the colon is part of the selector: @selector(changeIconState:)
.
Second, actions are methods that take a particular set of parameters — you can't just use any method as an action. Usually, actions look like this:
- (void)myAction:(id)sender;
where sender is a pointer to the object that's sending the action. In your code, when thisIconButton is tapped, that button would be passed as the sender.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With