• 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
Re: Saving only required files in a file wrapper?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Saving only required files in a file wrapper?


  • Subject: Re: Saving only required files in a file wrapper?
  • From: Keith Blount <email@hidden>
  • Date: Thu, 8 May 2008 04:30:08 -0700 (PDT)

Apologies for so soon a follow up, but I've just been experimenting with -writeToURL:ofType:forSaveOperation:originalContentsURL:error: and the results are disastrous. It turns out that *every single time* it is invoked, absoluteURL is a temporary location and *not* the original URL. So to use this method successfully I would need to copy the whole file package across to that location every time, which is exactly what I _don't_ want to do. This seems a little insane to me. There must be a mechanism in place that just lets you save into a package folder without having to write the whole thing out every time...

Thanks again and all the best,
Keith

----- Original Message ----
From: Ken Thomases <email@hidden>
To: Graham Cox <email@hidden>
Cc: Keith Blount <email@hidden>; Cocoa-Dev List <email@hidden>
Sent: Thursday, May 8, 2008 3:36:05 AM
Subject: Re: Saving only required files in a file wrapper?

On May 7, 2008, at 9:06 PM, Graham Cox wrote:

> On 8 May 2008, at 10:26 am, Keith Blount wrote:
>
>> The trouble with all of these methods is that they tell you not to
>> rely on fileURL
>
> My interpretation of that advice is that at the time the read... and
> write... methods are called, the document hasn't set up -fileURL, so
> in that sense you can't rely on it (i.e. don't call -fileURL from
> within these methods). But the URL passed to the methods themselves
> as a parameter is definitely reliable. So provided you use the
> parameter you'll be fine.

I think it means more than that.  NSDocument tries to be smart about
atomic writes and backups.  The URL passed into the write... methods
is not expected to be the same as the document's current location on
disk.  You are to write the document, in whole, to the temporary
location provided to you (about which no assumptions should be made),
and then NSDocument will take care of swapping the newly-written
document with the old document and deleting the old document.

Obviously, this runs directly counter to Keith's desires.
Unfortunately, I don't know how to override these smarts in
NSDocument, other than perhaps what I described earlier with
NSFileWrapper.

-Ken



      ____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
_______________________________________________

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

  • Follow-Ups:
    • Re: Saving only required files in a file wrapper?
      • From: Michael Nickerson <email@hidden>
  • Prev by Date: Re: self registering NSValueTransformer and bindings
  • Next by Date: How to send email without using email client
  • Previous by thread: Re: Saving only required files in a file wrapper?
  • Next by thread: Re: Saving only required files in a file wrapper?
  • Index(es):
    • Date
    • Thread