Observe NSWindowWillCloseNotification via NSNotificationCenter. You will get notified. The delegate should get the notification but it's possible the delegate is getting set nil prior.
On May 13, 2012, at 6:18 PM, Graham Cox wrote: > 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 protected]) > > 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/jamiejj%40gmail.com > > This email sent to [email protected] _______________________________________________ Cocoa-dev mailing list ([email protected]) 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 [email protected]
