Type Method

removeOtherVersionsOfItem(at:)

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

Declaration

class func removeOtherVersionsOfItem(at url: URL) throws

Parameters

inFileURL

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

outError

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

true if the older file versions were removed successfully or false if an error occurred.

Discussion

This method removes all versions except the current one from the version store, freeing up the associated storage space.

You should always remove file versions as part of a coordinated write operation to a file. In other words, always call this method from a block passed to a file coordinator object to initiate a write operation. Doing so ensures that no other processes are operating on the file while you remove the version information.

If successful, subsequent requests for the versions of the file reflect that only the current version is available. You can use this method to free up disk space by removing versions that are no longer needed.

See Also

Replacing and Deleting Versions

func replaceItem(at: URL, options: NSFileVersion.ReplacingOptions) -> URL

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

func remove()

Remove this version object and its associated file 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