0

How can I display an NSAlert when an NSWindow attempts to close? This will also have to be turned on and off.

Harry Johnston
  • 35,639
  • 6
  • 68
  • 158
Matt S.
  • 13,305
  • 15
  • 73
  • 129

1 Answers1

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
  • 1
    Note 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