KVO / Core Data question
KVO / Core Data question
- Subject: KVO / Core Data question
- From: "Paul L. Gribble" <email@hidden>
- Date: Wed, 14 Dec 2005 11:49:27 -0500
- Thread-topic: KVO / Core Data question
I have an entity "Trip" that has a to-many relationship to another entity,
"Transaction" via a relationship called "transaction".
The Trip entity has a key called "balance" whose value I want to depend on
the sum of all of the "amount" keys of each transaction.
I understand from reading Apple's Core Data FAQ (pg. 108-109) that it's not
possible to do this using setKeys:triggerChangeNotificationsForDependentKey,
where the key would be a key-path (e.g. email@hiddent).
The FAQ suggests two solutions - one, use KVO to register the parent as an
observer of the relevant attribute of all the children; and one must then
add and remove the parent as an observer, each time child objects are added
to or removed from the relationship. This seems not very efficient compared
to the second suggestion:
register the parent with the application's notification center as an
observer of its managed object context. This seems like less coding to me,
but there are no examples. Can anyone provide, or point me to, a code
snippet showing how one would do this?
Thanks,
_______________________________________________
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