• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
-selectedRow incorrect when NSTableView is being edited?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

-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.

  • Prev by Date: Re: Cocoa really needs to be thread-safe
  • Next by Date: class method list
  • Previous by thread: RE: Emptying an NSTextView
  • Next by thread: class method list
  • Index(es):
    • Date
    • Thread