Re: NSKeyedArchiver - better ways to autosave documents?
Re: NSKeyedArchiver - better ways to autosave documents?
- Subject: Re: NSKeyedArchiver - better ways to autosave documents?
- From: Keith Blount <email@hidden>
- Date: Wed, 31 Aug 2005 15:14:06 -0700 (PDT)
Many thanks for the replies.
The journalling idea sounds a good one - my document
is a bundle, so saving the journal inside the file
shouldn't be a problem. The problem is only in
figuring out how best to set it up. At the moment,
this is how my app works:
- If a folder is added, it is virtual - it is saved in
the NSKeyedArchiver-archived file (one of my custom
outline view node objects).
- If a document is added, the same happens as for a
folder, but an RTFD file is also saved inside the
bundle for storing the text (so that in a worst-case
scenario where the project file gets completely
corrupted, the user can still recover most of his or
her hard work).
To journal changes, I could archive the newly added
document/node in the journal file, and it would need
the ID of its parent node (each node is assigned a
unique project ID int) and the index at which it was
added (which is a bit more complicated than a
dictionary can handle, so I might need to make a
custom class just for the journal). The part I find
hard to figure out is, what if the user changes the
place or the title or any other attributes of that
node before it is saved? Would I just keep the ID
against the (eg.) title change and then make sure that
if I ever need to use the journal file, the changes
get read in in the same order they were added? Sorry,
just thinking aloud here as this seems like a sensible
approach but I am not sure how to go about
implementing it...
Many thanks again for the helpful reply, much
appreciated.
Cheers,
Keith
--- Guy English <email@hidden> wrote:
> >Programs managed to auto-save quickly before
> CoreData
> >came along, so there must be another solution.
>
> Instead of autosaving all the time you could keep a
> journal of what was done. When a file is added, log
> that, when a file is removed or moved in the list
> log that, etc. When you do a real save remove the
> journal. If you open a document and it's journal is
> still there then you probably crashed. Load the
> document as normal, run through the journal applying
> each change, resave immediately, and remove the
> journal. This way 'Autosave' should be quick and in
> a catastrophic case the user will only have to put
> up with a longer document load time. It also has the
> advantage that, no matter how big your document,
> saving off the actions will have a constant time.
>
> This would work much easier if your document was a
> bundle but you could stash the journal in
> application support if needed.
>
> Hope that helps,
> Guy
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden