• 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: makeDocumentForURL:nil withContentsOfURL:fileURL causing deletion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: makeDocumentForURL:nil withContentsOfURL:fileURL causing deletion


  • Subject: Re: makeDocumentForURL:nil withContentsOfURL:fileURL causing deletion
  • From: Jerry Krinock <email@hidden>
  • Date: Sun, 09 Feb 2014 00:29:52 -0800

On 2014 Feb 08, at 11:43, Trygve Inda <email@hidden> wrote:

> However, if I close the window (thus closing the document) and choose to not
> save, the file package at fileURL is deleted.

In order to keep a critical document from being deleted in this way, I think you should save it in code (“programatically”) before the user even sees it.  Then, the user will never presented with the choice of whether to save or delete.

Due to the intricacies of NSDocument, this may be a little hairy.  If your document is not based on Core Data, try…

-[NSDocument writeSafelyToURL:ofType:forSaveOperation:error:]

If it is based on Core Data, try…

-[NSManagedObjectContext save:]

And then, I’ve found, in order to satisfy NSDocument’s bean counters and avoid future dialogs about your document being “moved”, “changed by another application”, etc., you also need to do this…

-[NSDocument saveToURL:ofType:forSaveOperation:error:]

Particularly if your document is Core Data, this reply from Ben Trumbull of Apple will be of interest…

http://lists.apple.com/archives/cocoa-dev/2009/May/msg01187.html

The current version of the code being discussed in that thread is here…

https://github.com/jerrykrinock/CategoriesObjC/blob/master/NSPersistentDocument+Pathify.m


_______________________________________________

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: 
 >makeDocumentForURL:nil withContentsOfURL:fileURL causing deletion (From: Trygve Inda <email@hidden>)

  • Prev by Date: Re: dispatch_apply strange results
  • Next by Date: Re: dispatch_apply strange results
  • Previous by thread: Re: makeDocumentForURL:nil withContentsOfURL:fileURL causing deletion
  • Next by thread: Re: makeDocumentForURL:nil withContentsOfURL:fileURL causing deletion
  • Index(es):
    • Date
    • Thread