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

Re: NSDocument -canCloseDocumentWithDelegate::: not called when terminating


  • Subject: Re: NSDocument -canCloseDocumentWithDelegate::: not called when terminating
  • From: Kevin Perry <email@hidden>
  • Date: Mon, 23 Jul 2012 12:34:56 -0700


On Jul 23, 2012, at 10:51 AM, Markus Spoettl <email@hidden> wrote:

> On 7/23/12 6:22 PM, Kyle Sluder wrote:
>> I don't have my crazy autosave flowchart handy, but I *think* you should be
>> able to simply override -hasUnautosavedChanges to return YES if either super
>> returns YES or if your preferences file needs to be saved.
>> -autosaveWithImplicitCancellability:: is documented to check
>> -hasUnautosavedChanges, so I would assume that it is called unconditionally
>> at all places where AppKit wants to ensure the document is written to disk if
>> necessary.
>>
>> Of course, this assumes you are returning YES from +autosavesInPlace.
>

-autosaveWithImplicitCancellability: does check -hasUnautosavedChanges, but the quit procedure doesn't—it actually checks -isDocumentEdited. And when autosavesInPlace returns NO, overriding -isDocumentEdited to return YES will still result in the dirty dot in the close button, unless you go to great lengths to prevent the state from bubbling up to -[NSWindow setDocumentEdited:].

> 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?

You're talking about the "Do you want to save changes to this document" dialog when clicking the close button or quitting? The only way to bypass that is to override canCloseDocumentWithDelegate:… check for your special "-isDocumentEdited==YES, but don't show a panel" case, and invoke the shouldCloseSelector (after writing the preferences file) without calling super.


But really, if you and other developers feel there is a need for functionality to mark a document as needing saving, but without ever informing the user about it or giving them a chance to cancel it, then file an enhancement request for such an API.

-KP


_______________________________________________

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: Markus Spoettl <email@hidden>
References: 
 >NSDocument -canCloseDocumentWithDelegate::: not called when terminating (From: Markus Spoettl <email@hidden>)
 >Re: NSDocument -canCloseDocumentWithDelegate::: not called when terminating (From: Kyle Sluder <email@hidden>)
 >Re: NSDocument -canCloseDocumentWithDelegate::: not called when terminating (From: Markus Spoettl <email@hidden>)

  • Prev by Date: Re: 10.7 Full-Screen transition animation corrupts my UI - how to avoid?
  • Next by Date: Profound UITableView rendering-performance problem, but only at certain positions? No, not resolved.
  • Previous by thread: Re: NSDocument -canCloseDocumentWithDelegate::: not called when terminating
  • Next by thread: Re: NSDocument -canCloseDocumentWithDelegate::: not called when terminating
  • Index(es):
    • Date
    • Thread