Re: Document-based application and "complex" save
Re: Document-based application and "complex" save
- Subject: Re: Document-based application and "complex" save
- From: Jim Correia <email@hidden>
- Date: Wed, 15 Oct 2003 20:14:13 -0400
On Oct 15, 2003, at 9:58 AM, Rustam Muginov wrote:
I have a document-based application, which is using some complex file
structures. Imagine some object description stored in the text-based
files,
which could include other text files using relative paths.
As I am opening the document, I could read the object description, and
"dive" into the include statements to get additional data.
Then my application process the data, and could change some
information,
possibly even in the included files. As I need to save the document, I
am
facing the problem of writing several text files, the "main" object
description and possibly some included files.
I have overwritten the writeToFile:ofType: method, and it seems like
Cocoa
first asking me to save the file to some temporary folder.
If I would save the included files here, would Cocoa transfer them to
the
original position?
If no, are where any other ways to solve my problem?
I don't know what you mean by included files. Yes, this is documented
behavior. In the AppKit release notes it says:
NSDocument now implements document saving in a way that preserves,
when possible, various attributes of each document, including:
- Creation date.
- Permissions/privileges.
- The location of the document's icon in its parent folder's Icon
View Finder window.
- The value of the document's Show Extension setting.
Care is also taken to save documents in a way that does not break
any user-created aliases that may point to documents.
As a result, some methods in any subclass of NSDocument may now be
invoked with parameters that are different from what would have been
used in the past. For example, it is now more important than ever
that overrides of -writeToFile:ofType:originalFile:saveOperation:
and -writeToFile:ofType: make no assumptions about the file paths
that are passed as parameters, including:
- The location to which the file is being written. Likely as not the
file is being written to a hidden temporary directory.
- The name of the file being written. It is possible that the file
name will have no obvious relation to the document name.
- The relation of any file path being passed, including
originalFile, to the return value of [self fileName].
You should be able to use [self fileName] to determine the real
location of the file if you need to use it for calculating relative
paths, etc.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.