• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: applicationWillTerminate and NSDocumentController
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: An object should not retain its delegate, but what about its data source ?
  • Next by Date: Re: Launching a process with Admin Privileges asynchronously
  • Previous by thread: Re: An object should not retain its delegate, but what about its data source ?
  • Next by thread: Releasing by reference
  • Index(es):
    • Date
    • Thread