NSDocument -canCloseDocumentWithDelegate::: not called when terminating
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