tableView:disSelectRowAtIndexPath: で選択された UITableViewCell の文字列を取得する
例えば、tableView:disSelectRowAtIndexPath: メソッドで、そのセルが押された時に、そのセル文字列を利用したいことがあります。
その場合は、自分で UITableViewCell を NSIndexPath の値から作成して、取り出すことが出来ます。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
NSLog(@"%@", cell.textLabel.text);
}
NSIndexPath の値さえもないところから読むときは、NSIndexPath を作成します。
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];