• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Saving large NSDocument's
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Saving large NSDocument's


  • Subject: Saving large NSDocument's
  • From: Martin Hairer <email@hidden>
  • Date: Thu, 29 Sep 2005 21:33:26 +0100

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:
This email sent to email@hidden


  • Prev by Date: Re: Assistance with authentication
  • Next by Date: Re: Mouse Motion...
  • Previous by thread: Re: Background if Login Item launched
  • Next by thread: Obtaining information about the System's current cursor
  • Index(es):
    • Date
    • Thread