• 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: CoreData updating of NSTableView cells
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CoreData updating of NSTableView cells


  • Subject: Re: CoreData updating of NSTableView cells
  • From: Keith Wilson <email@hidden>
  • Date: Thu, 2 Mar 2006 21:35:31 +1100

I once had a similar problem with CoreData so in my DocumentController I have implemented

-(void)didUndoChange:(NSNotification*)notification
{
[self refreshAllViews]; //which invokes a refresh of every view in every document (as appropriate)
}


I do not know if this forced refresh is still necessary but I am now reluctant to remove it - it works.

Keith from DownUnder

On 02/03/2006, at 9:12 PM, Jason Swain wrote:

I have a CoreData application that shows a table view of core data objects. The table view has a custom cell for rendering the objects.

My (partial) core data model looks like this:

root --> group

where the relationship is one to many. I have bound a NSArrayController with a contentSet binding specifying root.groups as the model key path.

I set the data cell to a custom NSCell subclass. This cell uses the name attribute as well as calculating a count of the items in the group and displaying that number.

The problem occurs when I rename a group. I double click on a group to edit it, change the name and the display updates correctly. Now if I undo that change the group cell is not updated. The name has changed in the data model, as soon as I force the cell to repaint by changing the selection in the table view the correct (undone) name is painted. I need this repaint to happen as part of the undo.

I know this must be a common operation, so what is the correct way to handle it? It seems like I need to observe the name value for each cell, but I cannot do that in the NSCell subclass as this object is reused for multiple rows. It's possible to add an observer in the NSArrayController, but will be hard to keep up to date as groups are added and deleted, and this seems like a bit of a kludge.

Anyone know what to do here?

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40bigpond.net.au


This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >CoreData updating of NSTableView cells (From: Jason Swain <email@hidden>)

  • Prev by Date: NSArrayController content modification vs addObject:
  • Next by Date: Re: Programmatically setting the value of a bound TextField
  • Previous by thread: CoreData updating of NSTableView cells
  • Next by thread: NSArrayController content modification vs addObject:
  • Index(es):
    • Date
    • Thread