I'm using a Table View in a Cocoa application. I have set the double click action to do the following method when it occurs:
- (void)doubleClickInTable:(id)sender {
int rowIndex = [sender selectedRow];
if (rowIndex != -1) {
[userEditController setData:[[self users] objectAtIndex:rowIndex]];
[self showUserEditPanel];
}
}
As you can see, the EditController receives the object that is being edited. This object is the object that is located at rowIndex of the source array. This works very well most of the time, but once I started testing the sorts it is setting the wrong object. This is because the index of the clicked row in the table is different then the source array due to the sort moving rows around.
How do I fix this issue?