CoreData updating of NSTableView cells
CoreData updating of NSTableView cells
- Subject: CoreData updating of NSTableView cells
- From: Jason Swain <email@hidden>
- Date: Thu, 2 Mar 2006 10:12:14 +0000
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:
This email sent to email@hidden