I’m developing an App and at some point I have several uitableview.
I want to know outside the delegate methods, an action for instance, if the tableviews have a selected cell and which one.
I tried to use: (NSIndexPath *)indexPathForSelectedRow but it doesn’t work, because if I don’t have a selected cell the [(NSIndexPath *) row] returns “0” and not nil
could you please give any help??
thanks..
Your method is correct – indexPathForSelectedRow indeed returns nil if no cell is selected. But if you try to send message to nil object and use the value returned it will be 0, so you need to test if path value is nil or not before trying to get cell’s row from it:
P.S. nil is just a typecasted 0, so in practise they are the same thing.