To my knowledge, you can only retrieve progress feedback using the
Ubiquitous Item Downloading Status Constants which provides only 3 states:
- NSURLUbiquitousItemDownloadingStatusCurrent
- NSURLUbiquitousItemDownloadingStatusDownloaded
- NSURLUbiquitousItemDownloadingStatusNotDownloaded
So you can't have a quantified progress feedback, only partial aka downloaded or not.
To do so, you need to prepare and start your NSMetadataQuery, add some observers and check the downloading status of your NSMetadataItem using the NSURLUbiquitousItemDownloadingStatusKey key.
self.query = [NSMetadataQuery new];
self.query.searchScopes = @[ NSMetadataQueryUbiquitousDocumentsScope ];
self.query.predicate = [NSPredicate predicateWithFormat:@"%K like '*.yourextension'", NSMetadataItemFSNameKey];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(queryDidUpdate:) name:NSMetadataQueryDidUpdateNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(queryDidFinishGathering:) name:NSMetadataQueryDidFinishGatheringNotification object:nil];
[self.query startQuery];
Then,
- (void)queryDidUpdate:(NSNotification *)notification
{
[self.query disableUpdates];
for (NSMetadataItem *item in [self.query results]) {
NSURL *url = [item valueForAttribute:NSMetadataItemURLKey];
NSError *error = nil;
NSString *downloadingStatus = nil;
if ([url getResourceValue:&downloadingStatus forKey:NSURLUbiquitousItemDownloadingStatusKey error:&error] == YES) {
if ([downloadingStatus isEqualToString:NSURLUbiquitousItemDownloadingStatusNotDownloaded] == YES) {
// Download
}
// etc.
}
}
[self.query enableUpdates];
}