Reputation: 25
i have a NSTableView on a window, the data is populated using a NSMutableArray and that is Ok
after selecting a rows, when i check in code
[myTableView selectedRow];
or
[myTableView clickedRow];
both return null
Can anyone help?
Upvotes: 0
Views: 338
Reputation: 96353
selectedRow
and clickedRow
each return an NSInteger
, not an object. They're returning 0, which is the index of the first row.
If you print 0
as if it were an object (e.g., with NSLog(@"%@", [myTableView selectedRow])
), it will print as nil
, simply because that's what nil
is: 0
as an object pointer.
Of course, this assumes that myTableView
actually refers to a table view in the first place. If myTableView
does not yet point to a table view (i.e., the myTableView
variable itself holds nil
), any message to it will in turn return 0
(which, again, looks like nil
if you treat it as an object).
If selectedRow
returns 0
when the first row isn't selected or there are no rows, or clickedRow
returns 0
when the first row hasn't been clicked, make sure myTableView
points where you expect it to.
(I'm deliberately leaving the more specific explanation of the problem and its solution to you, Jaggu, since you said in the comments that you found it already.)
Upvotes: 2