Re: NSDocument save incremental file package in-place
Re: NSDocument save incremental file package in-place
- Subject: Re: NSDocument save incremental file package in-place
- From: Trygve Inda <email@hidden>
- Date: Sun, 02 Mar 2014 06:43:42 -0800
- Thread-topic: NSDocument save incremental file package in-place
> You also need to overwrite
> - (void)setFileURL:(NSURL *)absoluteURL
>
> in which you call super and then update your stored wrapper (if you have one
>
already) using -[NSFileWrapper readFromURL:options:error:].
>
> You need to do this because the filewrapper you return in -fileWrapperOfType::
>
gets written to a temp location and moved in place. That causes all
> references
to all the files and folders the wrapper and its subwrappers point
> to to move
and to become invalid as a result, once the save is complete.
> Updating ensures
the references are valid for the next go.
I have reduced it further:
-(BOOL)readFromFileWrapper:(NSFileWrapper *)fileWrapper ofType:(NSString
*)typeName error:(NSError **)outError
{
[self setDocumentFileWrapper:fileWrapper];
}
-(NSFileWrapper *)fileWrapperOfType:(NSString *)typeName error:(NSError
**)outError
{
return documentFileWrapper;
}
If the original file package read in has 7500 files, it takes 40 seconds to
save. It is structured like this:
-Root
- plist file (about 20mb)
- Folder containing 3750 image files of about 50kb each
- Folder containing 3750 image files of about 100kb each
Total size of the package is 550mb
The above code makes no changes at all to the documentFileWrapper and at
least for the first save, should be fine to write in no significant time.
_______________________________________________
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