Q:

When is [NSWindowDelegate windowWillClose] called?

I have observed that windowWillClose is called when the user closes a window but is NOT called when the window is closed because of app termination.
Now, for me this is a good thing because I want a certain piece of code to run when the window is closed but not at shutdown.
The reason for the question is that I cannot see why this should be the case from the Apple docs (all it says is "Tells the delegate that the window is about to close."). Can I rely on this behaviour not being "fixed" in future Cocoa versions?

A:

It's impossible to know for sure what Apple will do in the future. However, that has been the behavior for as long as I've been programming Cocoa. My guess would be that it's not going to change any time soon, especially since this is in a pretty mature part of the framework. But that's just my guess.

