brimstone
brimstone

Reputation: 3400

Ask user if they want to quit OS X application

Similarly to apps like Microsoft Word and Garageband, I want have a dialog before my app is closed asking if the user wants to quit because there is unsaved content. With these apps, a small black dot appears in the close button on the window. Is there a way I can do this in Swift?

Upvotes: 1

Views: 184

Answers (1)

brandonscript
brandonscript

Reputation: 72885

In Objective-C it's:

windowShouldClose:

...via NSWindowDelegate

You should be able to use this in Swift as well.

As for marking as edited, you want the setDocumentEdited: method.

Upvotes: 1

Related Questions