iphone - how know if uitableview has a selected cell -
i'm developing app , @ point have several uitableview. want know outside delegate methods, action instance, if tableviews have selected cell , one.
i tried use: (nsindexpath *)indexpathforselectedrow
doesn't work, because if don't have selected cell [(nsindexpath *) row]
returns "0" , not nil
could please give help??
thanks..
your method correct - indexpathforselectedrow indeed returns nil if no cell selected. if try send message nil object , use value returned 0, need test if path value nil or not before trying cell's row it:
nsindexpath *path = [table indexpathforselectedrow]; if (path){ row = [path row]; ... } else{ // no cell selected }
p.s. nil typecasted 0, in practise same thing.
Comments
Post a Comment