Select NSTableView row programmatically and call method
I have an NSTable开发者_JAVA百科View that I add objects to (through core data). I came across this in my searches:
NSIndexSet *indexSet = [NSIndexSet indexSetWithIndex:1];
[tableView selectRowIndexes:indexSet byExtendingSelection:NO];
which works, but the problem is when I replace 1 with [myarray count]
it doesn't select the last row.
My second question is when I have an IBAction hooked up to the table view to automatically call it when a row is selected, what is the sender? EDIT: Solved this one thanks to a good old NSLog
For the first question indexes are normally zero based. If I have
| row 0 | row 1 | row 2 | row 3 |
| item 1| item 2| item 3 | item 4 |
The count will be 4
but the last index will be 3
.
I'm not sure on the second answer I only know iOS at the moment.
精彩评论