Hi In my current project I have a controller object, that the view can bind to, with the following key path:
parameterInfo.<parameterName>.<attributeName> "parameterInfo" is a literal key name, <parameterName> maps to a parameter in a plug-in, and must be resolved at run-time. <attributeName> is one of several attribute names, such as "minValue", "maxValue" etc. There is a value object that represents parameterInfo, which is of class PBH_ParameterInfo. Since the information in the tree rarely changes, I thought it would be easier to make it immutable, so the parameterInfo object will return the same (pointer equal) NSDictionary object for each key throughout its entire lifetime. When the info in the tree changes, the controller just makes a new parameterInfo instance, and replaces the entire tree with [self setParameterInfo:newParameterInfo]. What happens then is: 1) The view correctly updates, meaning it must have received the notification. 2) The old parameterInfo object is correctly deallocated. 3) I get an error in the console saying the parameterInfo object is being deallocated while there are still observers attached. These observers are clearly registered under-the-hood by NSObject's (?) implementation. When the controller object is asked to register an observer for the key path parameterInfo.linearGain.maxValue, it goes to the next property in the chain (parameterInfo), and registers some sort of proxy pbject as an observer for linearGain.maxValue. So my question is who is responsible for removing the observation when it is no longer needed, and how shall I make it happen The Right Way? The old object is being deallocated by NSAutoreleasePool, so all observers are already notified that the parameterInfo property has changed. Shouldn't NSObject's implementation already know that the observation is no longer needed? After all, the old PBH_ParameterInfo instance is no longer part of the original key path being observed. If you say don't make the parameterInfo object immutable, instead create one mutable KVO-compliant object that stays there for the controller's life, that shouldn't be hard to do. I just want to learn how it's supposed to work. Per _______________________________________________ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com