I have one button in each cell of a UITableView. Now i want to bind each button to its action method in function:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { ...}
Here is my trying code:
NSString* functionNamePrefix = @"actionMethod_";
NSString* functionName = [functionNamePrefix stringByAppendingString:[NSString stringWithFormat:@"%d",indexPath.row]];
SEL selectorFromString = NSSelectorFromString(functionName);
[button addTarget:self action:@selector(selectorFromString:) forControlEvents:UIControlEventTouchDown];
The failure is : action selector take "selectorFromString" as a function name, but the SEL i convert from string.
Any suggestion? TIA!