Instance Method

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 NSFileVersion.ReplacingOptions.

error

On input, a pointer to an error object. If an error occurs, this pointer is set to an NSError object with information about the error.

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

func remove()

Remove this version object and its associated file from the version store.

class func removeOtherVersionsOfItem(at: URL)

Removes all versions of a file, except the current one, from the version store.

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