UITableViewの各セルに1つのボタンがあります。次に、各ボタンを関数内のアクションメソッドにバインドします。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { ...}
これが私の試してみるコードです:
NSString* functionNamePrefix = @"actionMethod_";
NSString* functionName = [functionNamePrefix stringByAppendingString:[NSString stringWithFormat:@"%d",indexPath.row]];
SEL selectorFromString = NSSelectorFromString(functionName);
[button addTarget:self action:@selector(selectorFromString:) forControlEvents:UIControlEventTouchDown];
失敗は次のとおりです。アクションセレクターは関数名として「selectorFromString」を取りますが、SELは文字列から変換します。
なにか提案を?TIA!