Re: Deep sleep and file wrappers?
Re: Deep sleep and file wrappers?
- Subject: Re: Deep sleep and file wrappers?
- From: Ken Thomases <email@hidden>
- Date: Wed, 7 May 2008 10:03:23 -0500
I don't have experience with NSDocument-based applications, so take
the following with a grain of salt...
On May 6, 2008, at 1:27 PM, Keith Blount wrote:
I have an application that saves its information as a file package.
My NSDocument subclass overrides -saveDocument: to save individual
files within the project folder (because there can be hundreds of
files and I wouldn't want to save the whole file wrapper every time
a single file is changed).
From the docs, this doesn't seem like the right way to customize
saving. Overriding -saveDocument: may catch some cases of save
attempts, but I suspect there are other times when other methods are
invoked directly. This document describes what you need to override
to customize how the document is saved:
http://developer.apple.com/documentation/Cocoa/Conceptual/Documents/Tasks/SubclassNSDocument.html
I never got to the bottom of the issue, and now another user has
reported the same thing. To recap: whilst my app was open, the
user's computer went into deep sleep (this was the case with the
first two users; the third user cannot remember the exact
circumstances but says his computer has had deep sleep problems
recently). When it came out of deep sleep, everything in the
project's file wrapper - that is, everything in the folder-with-
extension on disk - had been wiped. All that was in there were the
few files that were auto-saved _after_ deep sleep.
I can think of two possibilities:
1) some other method was invoked to save the document, but since you
didn't override it, it produced an empty document. The framework then
replaced the existing document on disk with the new empty document.
2) The framework sometimes juggles files to perform an "atomic"
document save operation. The writing methods of NSDocument are told
to write to a different, temporary location, then the original and the
newly saved document are swapped, then the backup is removed (unless -
keepBackupFile is overridden to return YES). If this happens in your
case, the new document will not be complete because of the way you're
only saving part of the document.
Good luck finding and fixing the problem,
Ken
_______________________________________________
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