Hey all. Me again. I'm having continuing issues with syncing my data model with my UI. I'd really appreciate some more input. Heck, if you can help and are around the Cupertino area, free lunch in a great cafeteria at a large computer company! :)
My model has an array of objects which in turn have arrays which hold objects that contain a property that holds a custom class named "category". So, it's nestled quite a bit down there. :)
[Controller] NSMutableArray *categories; // array of category objects. NSArrayController bound to panel for adds/deletes/mods
NSMutableArray *routes; // array of routelists [RouteList] [RouteList] // routelists have an array of job objects [Job] [Job] // jobs have a property called "category" which points to a category in the categories array [Job] NSMutableDictionary *properties { "name", "category", ... }
So, I need to make sure that if the user deletes a category from the panel, that the change gets propagated down into the bowels of my object graph. :) Adds work, and modifications do get propagated in the UI. But deletes aren't making it to the model. When I delete a category, then select the category popup for a Job that had it I get what appears to be it's 'ghost' (e.g.: "<Category: 0x4af3c8>").
From all the reading I've done to this point, this seems to be a "to-many" relationship? However, I'm not sure how to "address" all the "category" properties that live within all the Job objects scattered about in the RouteList arrays. So what I would like to accomplish is: "if a category is deleted from the main categories array, check each category property in every job contained in every routelist contained in the routes array. If the category property matches the category being deleted, set the property to nil."
My first try was to set my app controller to observe the local categories array for NSKeyValueObservingOptionOld changes. So, I get notified when I delete a category from the panel okay. Then I tried getting an enumerator for the RouteList array, then enumerated through it's Jobs objects looking for properties that matched the deleted category. It kind of worked, but feels clumsy and never did get reflected once a match was found.
Any direction would be appreciated.
#mikec |