On 2014 Feb 08, at 11:43, Trygve Inda <[email protected]> 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%2BPathify.m _______________________________________________ Cocoa-dev mailing list ([email protected]) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
