As a file is being saved, returns the attributes that should be written to a file or file package located by a URL, formatted to a specified type, for a particular kind of save operation.
- macOS 10.4+
The location to which the document is being written.
The string that identifies the document type.
The type of save operation.
The location of the previously saved copy of the document (if not
On return, if the attributes could not be returned, a pointer to an error object that encapsulates the reason they could not be returned.
A dictionary containing the attributes to be written, or
nil if unsuccessful.
Your subclass of
NSDocument can override this method to control the attributes that are set during a save operation. An override of this method should return a copy of the dictionary returned by its superclass’s version of this method, with appropriate alterations.
The set of valid file attributes is a subset of those understood by the
NSFile class. The default implementation of this method returns an empty dictionary for an
NSAutosave, or a dictionary with an appropriate
NSFile entry for any other kind of save operation. You can override this method to customize the attributes that are written to document files.
For backward binary compatibility with OS X v10.5 and earlier, the default implementation of this method returns a dictionary with
NSFile entries that have a value of 0 for
NSSave, in apps linked against OS X v10.5 or earlier.
For backward binary compatibility with OS X v10.3 and earlier, the default implementation of this method instead invokes
[self file if
file is overridden and the URL uses the
file: scheme. The save operation used in this case is never one of the autosaving ones:
NSSave is used instead.
The default implementation of
write automatically copies important attributes like file permissions, creation date, and Finder information from the old on-disk version of a document to the new one during an
NSAutosave. This method is meant to be used just for attributes that need to be written for the first time, for
absolute parameters are passed in for completeness; NSDocument’s default implementation doesn’t need to use them.