Re: NSDocument saving query
Re: NSDocument saving query
- Subject: Re: NSDocument saving query
- From: Quincey Morris <email@hidden>
- Date: Thu, 14 Apr 2016 12:09:01 -0700
- Feedback-id: 167118m:167118agrif8a:167118sSB7r0FuSt:SMTPCORP
On Apr 14, 2016, at 11:55 , Michael McLaughlin <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.
_______________________________________________
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