• 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: canAsynchronouslyWriteToURL:ofType:forSaveOperation: Prevent Quit?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: canAsynchronouslyWriteToURL:ofType:forSaveOperation: Prevent Quit?


  • Subject: Re: canAsynchronouslyWriteToURL:ofType:forSaveOperation: Prevent Quit?
  • From: Trygve Inda <email@hidden>
  • Date: Sun, 20 Apr 2014 16:29:07 -0700
  • Thread-topic: canAsynchronouslyWriteToURL:ofType:forSaveOperation: Prevent Quit?

> Do you override any other NSDocument saving methods? I believe NSDocument’s
> internal use of -performAsynchronousFileAccess… should cause it to delay
> NSApplication termination.
>
> --Kyle Sluder
>
> On Apr 20, 2014, at 1:01 PM, Trygve Inda <email@hidden> wrote:
>
>>>
>>>> On 20 Apr 2014, at 19:58, Trygve Inda <email@hidden> wrote:
>>>>
>>>> I return YES from
>>>>
>>>> canAsynchronouslyWriteToURL:ofType:forSaveOperation:
>>>>
>>>> Which works fine, but the user is able to quit the app while the save is in
>>>> progress. Is there way way to know when the save is complete so that I can
>>>> prevent quit before the save ends?
>>>
>>> If you play by NSDocument’s rules, the won’t actually terminate until saving
>>> is finished. How have you determined that this is not the case for your app?
>>> Is your save process doing anything weird?
>>
>> If I start a save and quit immediately, the file is not written. In my
>> Document class I override:
>>
>>
>> -(NSFileWrapper *)fileWrapperOfType:(NSString *)typeName error:(NSError
>> **)outError
>> {
>>  if ([self documentFileWrapper] == nil)
>>    [self setDocumentFileWrapper:[self createPackageDirectoryStructure]];
>>
>>  ...
>>
>>  [self unblockUserInteraction];
>>  return documentFileWrapper;
>> }
>>
>>
>> -(BOOL)canAsynchronouslyWriteToURL:(NSURL *)url ofType:(NSString *)typeName
>> forSaveOperation:(NSSaveOperationType)saveOperation
>> {
>>   return YES;
>> }
>

A small correction... This seems to only happen when I do a "Save As". If
the file is dirty and I do a "Save", the "file is dirty warning" catches the
quit.

However, a clean file (freshly saved) doing a "Save As", has nothing that
prevents a quit in the middle of the save.





_______________________________________________

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: canAsynchronouslyWriteToURL:ofType:forSaveOperation: Prevent Quit?
      • From: Kyle Sluder <email@hidden>
References: 
 >Re: canAsynchronouslyWriteToURL:ofType:forSaveOperation: Prevent Quit? (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: canAsynchronouslyWriteToURL:ofType:forSaveOperation: Prevent Quit?
  • Next by Date: Re: canAsynchronouslyWriteToURL:ofType:forSaveOperation: Prevent Quit?
  • Previous by thread: Re: canAsynchronouslyWriteToURL:ofType:forSaveOperation: Prevent Quit?
  • Next by thread: Re: canAsynchronouslyWriteToURL:ofType:forSaveOperation: Prevent Quit?
  • Index(es):
    • Date
    • Thread