RE: How to observe Core Data add/remove actions?
RE: How to observe Core Data add/remove actions?
- Subject: RE: How to observe Core Data add/remove actions?
- From: Arthur C. <email@hidden>
- Date: Thu, 15 Nov 2007 00:03:52 +0100
- Importance: Normal
> A more concrete example of what you're trying to accomplish (and how > you are trying to accomplish it) could really help us help you.
Okay (but it'll take more text to describe). I have a collection of Recipes (Core Data managed objects). Each recipe has 8 Items (also Core Data), with each item having several properties.
The interface is set up as a master/detail interface, so you can select (and add/remove) a recipe. The contents of that recipe are shown in the 'detail' table view: columns for the properties, rows for the Items.
Now, the property values of the 'items' in the selected Recipe are needed elsewhere in the program (non-Core Data part).
So those objects need to be informed about:
- when another recipe is selected
- when a recipe is removed or added
- changes in a property inside the (selected) recipe. From the interface, you can only make changes to the recipe that is selected, and only to a property from the Item that is selected.
- some recipe properties are dependent on other properties (by triggerChangeNotificationsForDependentKey), and they need to be observed as well.
A natural way for this seems to be to observe the corresponding array controllers. There is an array controller for Recipes, and an array controller selectedRecipe, which has a binding to Recipes.selection.
Now I'm still puzzled on how to do the observations correctly. Especially, on what to do from - observeValueForKeyPath.
Currently I try to read the new values directly from the array controller, or from [object selection], as there is a known bug in the 'change' dictionary here.
Thanks in advance,
Arthur C.
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/_______________________________________________
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