Skip navigation.
 
mlRe: Saving only required files in a file wrapper?
FROM : Graham Cox
DATE : Thu May 08 04:06:00 2008

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. If you call other parts of your code that need the URL 
from inside these methods, you also need to pass them the URL 
directly, don't let them fetch it using -fileURL.

A potential issue is if your users use Save As.. to save to a 
completely new file. In that case there is:

writeToURL:ofType:forSaveOperation:originalContentsURL:error:

so you have the original file URL as well so you can copy across other 
parts of the package to the new file. Again, there's no need to call -
fileURL at that time, which may or may not refer to the original file.

hth,

G.

Related mailsAuthorDate
mlRe: Saving only required files in a file wrapper? Keith Blount May 8, 02:26
mlRe: Saving only required files in a file wrapper? Graham Cox May 8, 04:06
mlRe: Saving only required files in a file wrapper? Ken Thomases May 8, 04:36