Instance Method

write(to:options:originalContentsURL:)

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

Declaration

func write(to url: URL, options: FileWrapper.WritingOptions = [], originalContentsURL: URL?) throws

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 FileWrapper.WritingOptions 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

true when the write operation is successful. If not successful, returns false 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

func write(toFile: String, atomically: Bool, updateFilenames: Bool)

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

Deprecated