How can I display an NSAlert when an NSWindow attempts to close? This will also have to be turned on and off.
Asked
Active
Viewed 989 times
1 Answers
1
NSWindow's delegate has a windowShouldClose: method that will allow you to customize this. There's also NSWindow's documentEdited methods that let you mark a document as having unsaved changes, which might interest you.

Chuck
- 234,037
- 30
- 302
- 389
-
1Note that if your window is part of a document based app you will already get an alert sheet by default if you try to close a window whose document is marked as dirty, meaning there are unsaved changes. (Influenced by window restoration, auto save APIs also) – uchuugaka May 12 '14 at 00:23