KVO de-observation difficulties when closing a window
KVO de-observation difficulties when closing a window
- Subject: KVO de-observation difficulties when closing a window
- From: Graham Cox <email@hidden>
- Date: Mon, 14 May 2012 11:18:12 +1000
This is proving a lot harder that I feel it should be.
I am KVO observing the accessory view property of an NSRulerView, so that I can install different views into the accessory area when the standard text controls are removed. The ownership of the NSRulerView is quite complicated, as it's part of an NSScrollView, which in turn is owned by a bunch of other views and ultimately the window.
I can remove my KVO observation in the window delegate's -windowWillClose: method, and that's fine as far as it goes. But it's not always called, leaving me with the dreaded 'KVO observers were still attached when an object was deallocated' error in some cases (in particular, when the 'Save' dialog shows up and Don't Save is clicked - maybe for other cases as well).
Is there a place I can reliably get notified when a window will close, no matter what pathway it took to close that window, whether a save was involved, whether it was closed by a manual click in the close button or closed by some other means, but BEFORE any of its internal structure is released (views in particular)? Surely there's a reliable place for this?
Ideally I'd prefer a delegate method since I'm not subclassing NSWindow in this case.
--Graham
_______________________________________________
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