Objective-c – UITableView – what row was selected

iphoneobjective-c

I have a question – how can I get a number of row selected in a table? I am assigning it manually to a variable. The problem is that if a row was deselected, my variable still keeps the old value.

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

Thank you in advance,
Ilya.

Best Solution

If you haven't implemented a delegate (see nduplessis), UITableView also offers:

- (NSIndexPath *)indexPathForSelectedRow