evictUbiquitousItemAtURL :error:
Removes the local copy of the specified cloud-based item.
Parameters
- url
- Specify the URL to a file or directory in iCloud storage.
- errorOut
- On input, a pointer to variable for an
NSError
object. If an error occurs, this pointer is set to anNSError
object containing information about the error. You may specifynil
for this parameter if you do not want the error information.
Return Value of [NSFileManager evictUbiquitousItemAtURL]
YES
if the local item was removed successfully or NO if it was not. If NO
is returned and errorOut is not nil
, an NSError
object describing the error is returned in that parameter.Discussion of [NSFileManager evictUbiquitousItemAtURL]
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.
Example of [NSFileManager evictUbiquitousItemAtURL]
-(BOOL) evictLocaleFile:(NSString *)name
{
NSURL *deletionURL = [[NSURL alloc] initFileURLWithPath:[ubiquityContainerURL path]];
deletionURL = [deletionURL URLByAppendingPathComponent:@"Documents" isDirectory:YES];
deletionURL = [deletionURL URLByAppendingPathComponent:name isDirectory:NO];
NSLog(@"EVICTION URL: %@", deletionURL.path);
NSError* err = nil;
BOOL didEvict = [[NSFileManager defaultManager] evictUbiquitousItemAtURL:deletionURL error:&err];
if (err != nil)
{
NSLog(@"Eviction error: %@", err.description);
}
return didEvict;
}