Re: NSDocument saving query (SOLVED)
Re: NSDocument saving query (SOLVED)
- Subject: Re: NSDocument saving query (SOLVED)
- From: Michael McLaughlin <email@hidden>
- Date: Thu, 14 Apr 2016 15:42:59 -0400
A solution appears to be
[newDoc saveDocumentWithDelegate:
which looks to be a simplified version of
[newDoc runModalSavePanelForSaveOperation:
In both cases, processing is deferred and the save selector has a BOOL parameter with the desired info (Save or Cancel).
Thanks.
> On Apr 14, 2016, at 3:09 PM, Quincey Morris <email@hidden> wrote:
>
> On Apr 14, 2016, at 11:55 , Michael McLaughlin <email@hidden <mailto:email@hidden>> wrote:
>>
>> What is the recommended way to capture a Cancel in this case? Any sample code available?
>
> If you look in the header file NSDocument.h, you’ll see that ‘saveDocumentAs' (by default) invokes ‘runModalSavePanelForSaveOperation:delegate:didSaveSelector:contextInfo’. If you think about it, that’s why there’s no return value from that method — there is no result until “later”.
>
> So, you need to invoke ‘runModalSavePanelForSaveOperation:delegate:didSaveSelector:contextInfo’ yourself, instead of ‘saveDocumentAs’, and deal with the fact that the completion is asynchronous. (AFAIK there is no block-based equivalent of this yet, so you have to deal with the awkward selector invocation, being careful to do proper memory management on the ‘contextInfo’ parameter, if you’re passing a reference counted pointer in that parameter, because ARC doesn’t manage it automatically.
>
--
Michael McLaughlin
email@hidden
_______________________________________________
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