I have a transient calculatedBalance property in my Account entity that is currently implemented as a read-only property returning: [self valueForKeyPath:@"transactio...@sum.amount"]
This appears to work but I'd like observers of this property to be notified every time a transaction is added, modified or removed. Having read the Core Data FAQ and several e-mails to the list I'm aware that one method is to register the parent as an observer of every child entity. I thought (and that may have been my first mistake) that implementing - (void)addTransactionsObject:(Transaction *)value and - (void)removeTransactionsObject:(Transaction *)value would do the trick so I added the following lines (as appropriate) to the XCode generated implementations... [value addObserver:self forKeyPath:@"amount" options:0 context:ACCOUNT_BALANCE_CONTEXT]; // added this to addTransactionsObject [value removeObserver:self forKeyPath:@"amount"]; // added this to removeTransactionsObject I'm logging these methods to confirm but when I add or remove transactions (a button triggers the remove: action of the NSArrayController) they simply aren't getting called. Am I overlooking something obvious? I implemented and logged - (void)addTransactions:(NSSet *)value and - (void)removeTransactions:(NSSet *)value too just in case but nada. Is this the right way of approaching this problem? Should each instance of Account be observing it's own "transactions" key and then figuring out which Transaction instance(s) it needs to start or stop observing? Is there some other approach I've completely overlooked? I considered the other route suggested by the Core Data FAQ which is to observe the application's managed object context but there'll be a few of these dependent keys floating around and I thought it could get messy quickly. Thanks in advance for any help! Matthew _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com