So, here's my case :
I'm developing a NON-standard document-based application and I want to handle the scenario of aborting the termination when there still are unsaved changes in any of the documents.
My initial idea is :
- User tries to quit the application (either through the
"Quit XXXXX"
menu item or by clicking the"X"
button) - Are there any modified documents?
- if NO : quit
- if YES : notify user that there are unmodified documents. if he wants to proceed, then quit. Else cancel termination.
So, I decided to do it the delegate-way.
In my Application delegate, I've implemented :
-windowToClose:
(triggered onNSWindowWillCloseNotification
)applicationShouldTerminate:
applicationShouldTerminateAfterLastWindowClosed:
Now, that's what I'm thinking. In the applicationShouldTerminate:
method :
- Return
NSTerminateNow
if no modified documents exist - Return
NSTerminateCancel
if there ARE modified documents. In that case, pop up an alert sheet or something like that and if user confirms he wants to quit, then call a[NSApp terminate:nil];
Is that the right way to go about it?
Any suggestions?