KVO/CoreData: Recompute a key when dependent key in relationship target changes?
KVO/CoreData: Recompute a key when dependent key in relationship target changes?
- Subject: KVO/CoreData: Recompute a key when dependent key in relationship target changes?
- From: Jim Correia <email@hidden>
- Date: Thu, 8 Jun 2006 12:41:01 -0400
I have an application with one entity.
Person
name (string)
children (to-many to Person)
parents (to-may to Person)
Person also has a plain old key "childrenSummaryString" which returns
a string of the form
(3) Ben, Matthew, Melissa
based on the Person's children.
Right now the string is just generated on the fly. KVO notifications
are not sent in the two cases where they need to be:
- the set of children changes
- the name of any of the children changes
What is the conceptually right way to implement this? How can I make
it work on 10.4.x (in case the answer is different :-))?
I've tried to using KVO. Person observers "name" on all of its
children. The problems I ran into with this approach:
- when to add/remove observers? the accessors are called for direct
set operations, but not for undo/redo
- when to finally remove observers - didTurnIntoFault is too late
since children is inaccessible at that time
Am I barking up the wrong tree here? Any direction on how to solve
the problems above?
Alternate solutions? (Should person, when its name changes, send a
message to all of its children which forces them to recompute the
summary string?)
The current stripped down example (no KVO) can be grabbed from
http://idisk.mac.com/jimcorreia-Public - it is named PeopleExample.zip
Thanks,
Jim
_______________________________________________
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