Re: How to observe every child entity
Re: How to observe every child entity
- Subject: Re: How to observe every child entity
- From: Matthew Lindfield Seager <email@hidden>
- Date: Tue, 15 Sep 2009 09:00:28 +1000
2009/9/15 Kyle Sluder <email@hidden>:
> If the only reason you want this is so that observers of calculatedBalance
> are notified when transactions changes (and therefore calculatedBalance),
> implement -keyPathsAffectingCalculatedBalance: to return a set that includes
> @"transactions".
That was my original implementation but unless I was doing something
wrong it only updates when the transactions relationship changes (i.e.
add or remove a transaction). I need that behaviour but I also need it
to update if an individual transaction's balance is changed.
The FAQ and KVO programming guide
(http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CoreData/Articles/cdFAQ.html
and http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/KeyValueObserving/Concepts/DependentKeys.html)
both have the same info and point me to observing either every child
or the managed object context (as per my original post) but the devil
is in the detail.
Although, as I write this I've just had a thought that I'm probably
over-complicating things... Instead of trying to observe every child
by monitoring the to-many transactions relationship perhaps I can
simply flip the problem around. It should be quite simple to add the
parent account as an observer in the transaction implementation (and
then if the account relationship changes just remove the old parent as
an observer and add the new one). I'll try that approach and report
back. Apologies for wasting people's time if that's what I should have
been doing all along!
Matt
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden