indexPath
有効な引数を渡す必要があります。呼び出しスコープで宣言していない場合、そのエラーが発生します。試す:
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:ROW_YOU_WANT_TO_SELECT inSection:SECTION_YOU_WANT_TO_SELECT]
[self tableView:playListTbl didSelectRowAtIndexPath:indexPath];
ROW_YOU_WANT...
は、選択したい行とセクションに置き換えます。
ただし、これを直接呼び出すべきではありません。内部で行われている作業tableView:didSelectRowAtIndexPath:
を個別のメソッドに抽出し、それらを直接呼び出します。
indexPathsForSelectedRows
更新された質問に対処するには、メソッド onを使用する必要がありますUITableView
。次のように、文字列の配列の配列からテーブル セルのテキストを入力していると想像してください。
- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tv dequeue...];
NSArray *rowsForSection = self.sectionsArray[indexPath.section];
NSString *textForRow = rowsForSection[indexPath.row];
cell.textLabel.text = textForRow;
return cell;
}
次に、選択したすべてのテキストを取得するには、次のようにします。
NSArray *selectedIndexPaths = [self.tableView indexPathsForSelectedRows];
NSMutableArray *selectedTexts = [NSMutableArray array];
for (NSIndexPath *indexPath in selectedIndexPaths) {
NSArray *section = self.sectionsArray[indexPath.section];
NSString *text = section[indexPath.row];
[selectedTexts addObject:text];
}
selectedTexts
その時点で、選択したすべての情報が含まれます。うまくいけば、その例は理にかなっています。