Instance Method


Writes a file wrapper’s contents to a given file-system node.


- (BOOL)writeToFile:(NSString *)path atomically:(BOOL)atomicFlag updateFilenames:(BOOL)updateFilenamesFlag;



Pathname of the file-system node to which the receiver’s contents are written.


YES to write the file safely so that:

  • An existing file is not overwritten

  • The method fails if the file cannot be written in its entirety

NO to overwrite an existing file and ignore incomplete writes.


YES to update the receiver’s filenames (its filename and—for directory file wrappers—the filenames of its sub–file wrappers) be changed to the filenames of the corresponding nodes in the file system, after a successful write operation. Use this in Save or Save As operations.

NO to specify that the receiver’s filenames not be updated. Use this in Save To operations.

Return Value

YES when the write operation is successful, NO otherwise.


Beginning with OS X v10.6, the preferred method of referring to files is with a file:// URL. Therefore, this method has been deprecated in favor of writeToURL:options:originalContentsURL:error:.

See Also

Writing Files

- writeToURL:options:originalContentsURL:error:

Recursively writes the entire contents of a file wrapper to a given file-system URL.