0
votes

I have an NSTableView 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

1
try to log [myarray count] and compare with your table datasource -(NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView return valueuser756245
@vince they're both returning the same value, the row just isn't being selectedMatt S.

1 Answers

1
votes

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.