How to find out if a uitableview has a selected cell

I am developing an application, and at some point I have a few uitableview. I want to know outside the delegate methods, for example, the action if there is a selected cell in tableviews and which one.

I tried to use: (NSIndexPath *)indexPathForSelectedRowbut it does not work, because if I do not have a selected cell, it [(NSIndexPath *) row]returns "0" and not nil

Could you help me?

thank..

+5
source share
1 answer

- indexPathForSelectedRow nil, . , 0, , , :

NSIndexPath *path = [table indexPathForSelectedRow];
if (path){
   row = [path row];
   ...
}
else{
 // No cell selected
}

P.S. nil - 0, .

+20

All Articles