Instance Method


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


- (NSURL *)replaceItemAtURL:(NSURL *)url options:(NSFileVersionReplacingOptions)options error:(NSError * _Nullable *)error;



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.


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


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.


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

- removeAndReturnError:

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

+ removeOtherVersionsOfItemAtURL:error:

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