• 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
Re: Removing table rows while editing?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Removing table rows while editing?


  • Subject: Re: Removing table rows while editing?
  • From: Brian Webster <email@hidden>
  • Date: Thu, 7 Feb 2002 17:29:36 -0600

On Thursday, February 7, 2002, at 03:42 PM, cocoa-dev-
email@hidden wrote:

I have a button that removes items from the table view (a single-column
list) by deleting them from the data source and reloading the table. But if
the cell is the last in the list, an exception is raised and all my lists
stop displaying properly. If the cell is in the middle of the list, the row
is removed and then the edited contents replace an adjacent row. This,
combined with the fact that the exception seems to happen when Cocoa is
trying to replace an item, leads me to believe that for some reason the
message to update the data source with the results of the edit happens
_after_ the table is reloaded from the row removal. How do I avoid this? I
presume the thing to do is cancel the edit before removing the row, forcing
an additional reload if necessary -- but I don't know how to do it.

To cancel the cell's edit session, you send an endEditing: message to the cell itself, which you have to get from the appropriate table column. The NSText object that you pass in is the control's (i.e. your table view) field editor.

int row = [myTable editedRow], column = [myTable editedColumn];

if(row != -1)
{
NSTableColumn *tableColumn = [[myTable tableColumns] objectAtIndex:column];
NSCell *cell = [tableColumn dataCellForRow:row];
[cell endEditing:[myTable currentEditor]];
}


--
Brian Webster
email@hidden
http://homepage.mac.com/bwebster
_______________________________________________
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: newbie question on 'Cocoa Programming for Mac OS X'
  • Next by Date: Re: newbie question on 'Cocoa Programming for Mac OS X'
  • Previous by thread: Removing table rows while editing?
  • Next by thread: Background Color opacity
  • Index(es):
    • Date
    • Thread