先谢谢你。
enter code here
- (void)processiCloudFiles:(NSNotification *)notification {
[_query disableUpdates];
[_iCloudNames removeAllObjects];
int totalItems = _query.resultCount; // it not update here
//OR: _query.results
}
- (void)startQuerying {
[self stopQuery];
_query = [self documentQuery];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(processiCloudFiles:)
name:NSMetadataQueryDidFinishGatheringNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(processiCloudFiles:)
name:NSMetadataQueryDidUpdateNotification
object:nil];
[_query startQuery];
}
- (void)stopQuery {
if (_query) {
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSMetadataQueryDidFinishGatheringNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSMetadataQueryDidUpdateNotification object:nil];
[_query stopQuery];
_query = nil;
}
}
- (NSMetadataQuery *)documentQuery {
NSMetadataQuery * query = [[NSMetadataQuery alloc] init];
if (query) {
[query setSearchScopes:[NSArray arrayWithObject:NSMetadataQueryUbiquitousDocumentsScope]];
NSString * filePattern = [NSString stringWithFormat:@"*.%@", FILE_EXTENSION];
[query setPredicate:[NSPredicate predicateWithFormat:@"%K LIKE %@",
NSMetadataItemFSNameKey, filePattern]];
}
return query;
}发布于 2014-04-29 04:18:02
当用户按“主页”按钮时,可以在“文档”文件夹中创建临时文件。这样做是因为用户可能会去设置设备并删除歌曲。
当用户转到应用程序时,您可以删除这个临时文件,以便iCloud可以刷新数据列表。
希望这能帮到你。
https://stackoverflow.com/questions/22658846
复制相似问题