isUbiquitousItemAtURL:
Returns a Boolean indicating whether the item is targeted for storage in iCloud.
- (BOOL)isUbiquitousItemAtURL:(NSURL *)url
Parameters
- url
- Specify the URL for the file or directory whose status you want to check.
Return Value of [NSFileManager isUbiquitousItemAtURL]
YES if the item is targeted for iCloud storage or NO if it is not. This method also returns NO if no item exists at url.Discussion of [NSFileManager isUbiquitousItemAtURL]
This method reflects only whether the item should be stored in iCloud because a call was made to the
setUbiquitous:itemAtURL:destinationURL:error: method with a value of YES for its flag parameter. This method does not reflect whether the file has actually been uploaded to any iCloud servers. To determine a file’s upload status, check the NSURLUbiquitousItemIsUploadedKey attribute of the corresponding NSURL object.
Example of [NSFileManager isUbiquitousItemAtURL]
- (BOOL)validateMenuItem:(NSMenuItem*)item
{
SEL action = [item action];
if (action == @selector(moveToOrFromCloud:))
{
BOOL isUbiquitous = [[NSFileManager defaultManager] isUbiquitousItemAtURL:[[self document] fileURL]];
[item setTitle:isUbiquitous ? @"Remove from Cloud": "Move to Cloud"];
[item setTag:isUbiquitous?0:1];
return [self.document fileURL] != nil;
}
return YES;
}