Re: applicationWillTerminate and NSDocumentController
Re: applicationWillTerminate and NSDocumentController
- Subject: Re: applicationWillTerminate and NSDocumentController
- From: PGM <email@hidden>
- Date: Wed, 1 Aug 2007 13:21:27 +0200
On 1 Aug 2007, at 00:18, Martin Wierschin wrote:
How can I get a list of open documents at quit and/or get it
before NSDocumentController does whatever magic it's doing to get
to the quit event before me?
I think you should be able to override "terminate:" in an
NSApplication subclass. Simply capture the document state before
you pass terminate to super.
IIRC terminate is not always called upon quit, only when the user
chooses Quit from the app-menu, not when the app is terminated when
the computer shuts down or restarts.
One annoying thing about the NSDocumentController is that it receives
the ...terminate notifications before the app's delegate (even though
the docs state otherwise), making it useless for purposes such as
yours. However, you can make a NSDocumentController subclass, and
override the method with the lovely name
reviewUnsavedDocumentsWithAlertTitle:cancellable:delegate:didReviewAllSe
lector:contextInfo:
However, this method is only called when there are unsaved documents,
so you may need to use both this method and applicationWillTerminate
to get a full list of documents at quit.
Hope this helps, Patrick
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden