• 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
NSDocument -canCloseDocumentWithDelegate::: not called when terminating
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSDocument -canCloseDocumentWithDelegate::: not called when terminating


  • Subject: NSDocument -canCloseDocumentWithDelegate::: not called when terminating
  • From: Markus Spoettl <email@hidden>
  • Date: Mon, 23 Jul 2012 17:12:47 +0200

Hello,

when I close my document window without terminating the application, -canCloseDocumentWithDelegate::: is called, independent of whether the document is dirty.

When I quit the application, -canCloseDocumentWithDelegate::: is only called if the document reports it is dirty. If it is not dirty, AppKit takes a shortcut calls into -close directly. NSDocumentController doesn't seem to be involved either.

Why do I need this?

My document is stored in a package that contains a preferences file. When the document is saved, the preferences file is saved as part of the package. So, if it is dirty at the time of closing it's going to be saved. If the document isn't dirty, I'd like to update the preference file only.

A good place would have been -canCloseDocumentWithDelegate::: because I can check whether the document is dirty and save the preferences file if necessary. That doesn't work if it's not getting called of course. -close is called after the document is saved, so the dirty flag there isn't helpful.

Are there better options to do a last-minute save? I do not want to change the design, meaning I don't want preferences to contribute to the change count state or even worse be undoable. Plus I do want the preferences to be stored in the package, not someplace else (restoration state for example).

Thanks for any pointers!

Regards
Markus
--
__________________________________________
Markus Spoettl
_______________________________________________

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

  • Follow-Ups:
    • Re: NSDocument -canCloseDocumentWithDelegate::: not called when terminating
      • From: Kyle Sluder <email@hidden>
    • Re: NSDocument -canCloseDocumentWithDelegate::: not called when terminating
      • From: Kevin Perry <email@hidden>
    • Re: NSDocument -canCloseDocumentWithDelegate::: not called when terminating
      • From: Fritz Anderson <email@hidden>
  • Prev by Date: Re: Design issue related to my problem with NSSound -isPlaying
  • Next by Date: Re: Profound UITableView rendering-performance problem, but only at certain positions?
  • Previous by thread: Re: Design issue related to my problem with NSSound -isPlaying
  • Next by thread: Re: NSDocument -canCloseDocumentWithDelegate::: not called when terminating
  • Index(es):
    • Date
    • Thread