Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Saving large NSDocument's



Hi, I have an NSDocument-based application which can potentially
take a very long time (more than a minute) to save a file and the resulting
file can be very large (up to several GB). Overriding


- (BOOL)writeToFile:(NSString *)fileName ofType:(NSString *)type;
- (BOOL)writeToURL:(NSURL *)url ofType:(NSString *)type;

doesn't sound like a good idea, since it seems that the AppKit expects these
functions to have produced the entire file upon return. Also, if I just spawn a
new thread from them, they would always have to return YES, even though I
would like to allow the user to cancel the file saving operation. I then tried to
override


-(void)saveToURL:(NSURL *)absoluteURL ofType:(NSString *)typeName forSaveOperation:(NSSaveOperationType)saveOperation
delegate:(id)delegate didSaveSelector:(SEL)didSaveSelector contextInfo:(void *)contextInfo


in such a way that it saves the file to a temporary location, then invokes the "super"
implementation when it's done and finally moves the file from the temporary location
to the correct one inside


- (BOOL)writeToURL:(NSURL *)url ofType:(NSString *)type;

This works fine, but of course it only works under MacOS 10.4. Furthemore it seems a bit
overkill to me to save to a temporary location before "writeToURL" is called since that
one is anyway given a temporary URL only which then gets moved to the correct location
by NSDocument... Does anybody out there know of any better / more standard way of
achieving this? Thanks a lot,


Martin

HairerSoft
http://www.hairersoft.com/

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.