相反轮询NSMetadataItem
更改的,你应该只听从NSMetadataQuery
更新和获取NSMetadataUbiquitousItemPercentDownloadedKey
一次(和更新UI)每次收到的更新时间。
(I 认为现有的NSMetadataItem对象在下载过程中不会更新,除非从下载过渡到完全下载)。
这里是听使用KVO NSMetadataQuery更新的方式:
// To register for KVO updates:
[query addObserver:self
forKeyPath:@"results"
options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld
context:nil];
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
// check that "object" is your metadata query then:
NSUInteger changeKind = [[change objectForKey:NSKeyValueChangeKindKey] unsignedIntegerValue];
switch (changeKind) {
case NSKeyValueChangeSetting:
// The whole array of results changed, update your model accordingly
// ...
break;
case NSKeyValueChangeReplacement:
// This is where you update your progress bar in most cases
// Enumerate [change objectForKey:NSKeyValueChangeNewKey], this is a list of NSMetadataItems that will have all the desired properties
break;
case NSKeyValueChangeInsertion:
// Handle a new document
// ...
break;
case NSKeyValueChangeRemoval:
// Handle a removed document
// ...
break;
}
}
如果仍然看到没有更新的进展,请提交错误报告与苹果。
显示您开发的代码。 – Apurv