Reputation: 913
I have an NSDocument
-based app where a window for the document may have child windows that need to be queried for changes before the document can close. So I tried to intercept the closing of the document window to do this, but I can't find a reliable way.
I tried to use -[Document canCloseDocumentWithDelegate:shouldCloseSelector:contextInfo:]
for this, but apparenty this is only called when the document has changes (signalled by -updateChangeCount
). If there are no changes, this never gets called.
My other attempt to use the view controller's viewWillDisappear
to update the document failed too, as this is too late to register any changes with the document, so they do not get saved (canCloseDocumentWithDelegate:...
has already been called at this point.)
What would be the best way to solve this?
Upvotes: 0
Views: 291
Reputation: 16660
Well, I'd say that if the child windows contains changes that have to asked for before the document is closed, the document has changes. And this should be reflected in the (main) document window. However, …
Likely -shouldCloseWindow:
should be called, if the document does not contain changes and therefore the document system does not ask for saving itself.
Upvotes: 2