-selectedRow incorrect when NSTableView is being edited?
-selectedRow incorrect when NSTableView is being edited?
- Subject: -selectedRow incorrect when NSTableView is being edited?
- From: Jim Balhoff <email@hidden>
- Date: Fri, 1 Nov 2002 18:30:36 -0500
Hi,
I am having a problem with NSTableView and determining the selected
row. The data source for my tableview keeps the data in an
NSMutableArray called "scores". When I want to delete a row, a button
press calls this action in the controller:
- (IBAction)removeScore:(id)sender
{
int row = [tableView selectedRow];
if (row != -1) {
[scores removeObjectAtIndex:row];
[self updateUI];
}
else {
NSBeep();
}
}
Most of the time this works great. BUT, if the tableview is being
edited, -selectedRow returns an index which is one greater than the row
that is selected/edited. This causes score 5 to be deleted instead of
score 4, for instance, if score 4 is selected. Or, if the last row is
being edited, it causes an attempt to delete an object that has an
"index beyond bounds" of the array.
Is this expected behavior which I'm just going to have to work around?
It seems rather odd - I would have expected to get -1 returned if it
weren't going to return the actual selected row.
Thanks,
Jim Balhoff
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.