Hi all, Can anyone think of a sitation where using removeObserver:forKeyPath: works correctly, then modernizing the code to use removeObserver:forKeyPath:context: breaks things?
Long story: I have a custom NSView subclass that exposes a custom binding. In bind: it does addObserver:forKeyPath:options:context:. In unbind: it does removeObserver:forKeyPath:. If I update unbind: to use the 'context' version it breaks. Specifically, if I have several of these views onscreen (all bound to the same NSObjectController) then remove all but one of the views from the view hierarchy, the remaining one no longer receives any KVO notifications. I've put logs everywhere, and subclassed NSObjectController and implemented add&removeObserver methods to log and call super. All the log output is the same in the working & broken cases except the deliberate difference between using removeObserver: with or without the context. I am surprised to see this backtrace however: -[MyObjectController removeObserver:forKeyPath:] -[NSObject(NSKeyValueObserverRegistration) removeObserver:forKeyPath:context:] () -[NSController removeObserver:forKeyPath:context:] () -[MyObjectController removeObserver:forKeyPath:context:] -[MyView unbind:] ... Odd that NSObjectController removeObserver:forKeyPath:context: calls removeObserver:forKeyPath:, no? Any clues would help... :) Thanks, -- ____________________________________________________________ Sean McBride, B. Eng s...@rogue-research.com Rogue Research www.rogue-research.com Mac Software Developer Montréal, Québec, Canada _______________________________________________ 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