UITableView - which row was selected?

My question is: how can I get the number of rows selected in the table? I assign it manually to a variable. The problem is that if the string was canceled, my variable still retains the old value.

What can I do? Is there a method in a UITableView that returns the number of the currently selected row?

Thanks in advance, Ilya.

+45
objective-c iphone
Mar 19 '09 at 20:12
source share
2 answers

If you have not implemented a delegate (see nduplessis), UITableView also offers:

- (NSIndexPath *)indexPathForSelectedRow 
+109
Mar 19 '09 at 20:34
source share

UITableViewDelegate will call

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 

when a row is selected. From this, you can easily define a string using indexPath.section and indexPath.row

+36
Mar 19 '09 at 20:29
source share



All Articles