मेरी जानकारी के लिए, आप केवल Ubiquitous Item Downloading Status Constants जो केवल 3 राज्यों को प्रदान करता है का उपयोग कर प्रगति प्रतिक्रिया प्राप्त कर सकते हैं:
- NSURLUbiquitousItemDownloadingStatusCurrent
- NSURLUbiquitousItemDownloadingStatusDownloaded
- NSURLUbiquitousItemDownloadingStatusNotDownloaded
तो आप नहीं कर सकते एक प्रमाणित प्रगति प्रतिक्रिया है, केवल आंशिक उर्फ डाउनलोड या नहीं।
ऐसा करने के लिए, आप को तैयार करने के लिए और अपनी NSMetadataQuery शुरू करते हैं, कुछ पर्यवेक्षकों जोड़ सकते हैं और NSURLUbiquitousItemDownloadingStatusKey कुंजी का उपयोग कर अपने NSMetadataItem को डाउनलोड करने की स्थिति की जांच की जरूरत है।
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];
फिर, एक NSMetadataQuery
से
- (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];
}
http://stackoverflow.com/a/23593943/4034301 यह उपयोगी –