• 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
KVO/CoreData: Recompute a key when dependent key in relationship target changes?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Segemented control and icon alignement...
  • Next by Date: Re: Distributed Objects, copying thereof
  • Previous by thread: Re: Segemented control and icon alignement...
  • Next by thread: Creating table cells with multiple controls
  • Index(es):
    • Date
    • Thread