Contents

replaceItem(at:options:)

Replace the contents of the specified file with the contents of the current version’s file.

Declaration

func replaceItem(at url: URL, options: NSFileVersion.ReplacingOptions = []) throws -> URL

Parameters

  • url:

    The file whose contents you want to replace. If the file at this URL does not exist, a new file is created at the location.

  • options:

    Specify 0 to overwrite the file in place; otherwise, specify one of the constants described in Replacingoptions.

Return Value

The URL of the file that was written, which may be different than the one specified in the url parameter.

Discussion

When replacing the contents of the file, this method does not normally replace the display name associated with the file. The only exception is when the file at url is of a different type than the file associated with this version object. In such a case, the file name remains the same but its filename extension changes to match the type of the new contents. (Of course, if filename extension hiding is enabled, this change is not noticeable to users.)

See Also

Replacing and Deleting Versions