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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
selectedRowandclickedRoweach return anNSInteger, not an object. They’re returning 0, which is the index of the first row.If you print
0as if it were an object (e.g., withNSLog(@"%@", [myTableView selectedRow])), it will print asnil, simply because that’s whatnilis:0as an object pointer.Of course, this assumes that
myTableViewactually refers to a table view in the first place. IfmyTableViewdoes not yet point to a table view (i.e., themyTableViewvariable itself holdsnil), any message to it will in turn return0(which, again, looks likenilif you treat it as an object).If
selectedRowreturns0when the first row isn’t selected or there are no rows, orclickedRowreturns0when the first row hasn’t been clicked, make suremyTableViewpoints 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.)