Instance Method

evictUbiquitousItemAtURL:error:

Removes the local copy of the specified cloud-based item.

Declaration

- (BOOL)evictUbiquitousItemAtURL:(NSURL *)url error:(NSError * _Nullable *)error;

Parameters

url

Specify the URL to a file or directory in iCloud storage.

error

On input, a pointer to variable for an NSError object. If an error occurs, this pointer is set to an NSError object containing information about the error. You may specify nil to ignore the error information.

Return Value

YES if the local item was removed successfully or NO if it was not. If NO is returned and error is not nil, an NSError object describing the error is returned in that parameter.

Discussion

Do not use a coordinated write to perform this operation. In macOS 10.7 or earlier, the framework takes a coordinated write in its implementation of this method, so taking one in your app causes a deadlock. In macOS 10.8 and later, the framework detects coordination done by your app on the same thread as the call to this method, to avoid deadlocking.

This method does not remove the item from the cloud. It removes only the local version. You can use this method to force iCloud to download a new version of the file or directory from the server.

To delete a file permanently from the user’s iCloud storage, use the regular NSFileManager routines for deleting files and directories. Remember that deleting items from iCloud cannot be undone. Once deleted, the item is gone forever.

See Also

Managing iCloud-Based Items

ubiquityIdentityToken

An opaque token that represents the current user’s iCloud identity.

URLForUbiquityContainerIdentifier:

Returns the URL for the iCloud container associated with the specified identifier and establishes access to that container.

isUbiquitousItemAtURL:

Returns a Boolean indicating whether the item is targeted for storage in iCloud.

setUbiquitous:itemAtURL:destinationURL:error:

Sets whether the item at the specified URL should be stored in the cloud.

startDownloadingUbiquitousItemAtURL:error:

Starts downloading (if necessary) the specified item to the local system.

URLForPublishingUbiquitousItemAtURL:expirationDate:error:

Returns a URL that can be emailed to users to allow them to download a copy of a cloud-based flat file item.