• 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: Intercept Save when closing NSDocument
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Intercept Save when closing NSDocument


  • Subject: Re: Intercept Save when closing NSDocument
  • From: Trygve Inda <email@hidden>
  • Date: Fri, 10 Feb 2017 09:30:09 -0800
  • Thread-topic: Intercept Save when closing NSDocument

On 2/10/17, 9:19 AM, "Keary Suska"
<cocoa-dev-bounces+cocoadev=email@hidden on behalf of
email@hidden> wrote:

>
>> On Feb 10, 2017, at 9:12 AM, Trygve Inda <email@hidden>
>>wrote:
>>
>> When I close an NSDocument, it puts up a sheet offering (Don¹t Save,
>> Cancel, Save).
>>
>> Is there a way to intercept this? I would like to disable the Save
>>button
>> for a demo version of our app. I could mark the document as having no
>> changes, but then it would just close directly and not allow a cancel
>> operation.
>>
>> I can easily disable the menu Save/Save As but clicking the Save button
>>in
>> the close-sheet window jumps right into the file writing methods in my
>> NSDocument subclass.
>>
>> Thanks for any ideas.
>
>I would start by overriding -saveDocument: and -saveDocumentAs: in your
>NSDocument subclass with a breakpoint so I can see what is being done. I
>might also start by subclassing
>-runModalSavePanelForSaveOperation:delegate:didSaveSelector:contextInfo:
>to see if that is the method used in these cases. Then there are also
>autosave issues if you intend to support autosave in your app...

Yup - I have overridden -saveDocument: and -saveDocumentAs:

They are called from the File-Save and File-Save As points, but not from
clicking Save in the “document is about to close” dialog. I am not
supporting Autosave as I am dealing with very large files.

Trygve





_______________________________________________

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


References: 
 >Intercept Save when closing NSDocument (From: Trygve Inda <email@hidden>)
 >Re: Intercept Save when closing NSDocument (From: Keary Suska <email@hidden>)

  • Prev by Date: Re: Intercept Save when closing NSDocument
  • Next by Date: Re: UI bindings
  • Previous by thread: Re: Intercept Save when closing NSDocument
  • Next by thread: Re: Intercept Save when closing NSDocument
  • Index(es):
    • Date
    • Thread