Re: NSDocument -canCloseDocumentWithDelegate::: not called when terminating
Re: NSDocument -canCloseDocumentWithDelegate::: not called when terminating
- Subject: Re: NSDocument -canCloseDocumentWithDelegate::: not called when terminating
- From: Markus Spoettl <email@hidden>
- Date: Mon, 23 Jul 2012 19:35:51 +0200
On 7/23/12 6:06 PM, Kevin Perry wrote:
I can't really recommend an approach that essentially lies about the "dirty"
state of a document. If you have something to write into the document bundle,
then the document is dirty and it should be declared so with the available
NSDocument APIs. If the existing APIs don't meet your needs for whatever
reason, file an enhancement request.
Also, NSDocument and NSFileWrapper (assuming you're using it) might not take
it very kindly if you modify the package outside of the normal -save… and
-write… APIs, especially if/when you adopt Autosave and iCloud.
To answer your question more directly—there is no public callback that is
invoked in every case on Quit when the document returns NO from
-isDocumentEdited or -hasUnautosavedChanges. In fact, sometimes nothing gets
invoked at all because when -isDocumentEdited returns NO, NSDocument enables
sudden termination, which allows -[NSApplication terminate:] to take
shortcuts and Shutdown/Restart/Logout to kill the app.
OK, I get your point and I'm not insisting on asking for trouble, so:
If there would be a way to tell NSDocument to forgo asking whether to save a
document if -isDocumentEdited returned YES, and instead just save it, that would
be a solution. All I want is a silent save, when only preferences need to be
saved (since I'm using file wrappers it would be quick too because I'm only
replacing the wrapper for my preferences).
I don't see how I could do that. Is there a way?
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