Instance Method

writeToURL:options:originalContentsURL:error:

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

Declaration

- (BOOL)writeToURL:(NSURL *)url options:(NSFileWrapperWritingOptions)options originalContentsURL:(NSURL *)originalContentsURL error:(NSError * _Nullable *)outError;

Parameters

url

URL of the file-system node to which the file wrapper’s contents are written.

options

Option flags for writing to the node located at url. See NSFileWrapperWritingOptions for possible values.

originalContentsURL

The location of a previous revision of the contents being written. The default implementation of this method attempts to avoid unnecessary I/O by writing hard links to regular files instead of actually writing out their contents when the contents have not changed. The child file wrappers must return accurate values when its filename property is accessed for this to work. Use the NSFileWrapperWritingWithNameUpdating writing option to increase the likelihood of that.

Specify nil for this parameter if there is no earlier version of the contents or if you want to ensure that all the contents are written to files.

outError

If an error occurs, upon return contains an NSError object that describes the problem. Pass NULL if you do not want error information.

Return Value

YES when the write operation is successful. If not successful, returns NO after setting outError to an NSError object that describes the reason why the file wrapper’s contents could not be written.

Discussion

See Also

Writing Files

- writeToFile:atomically:updateFilenames:

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

Deprecated

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software