如何检测iCloud中文件的更改时间? [英] How do you detect when a file is changed in iCloud?
本文介绍了如何检测iCloud中文件的更改时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在iCloud中更改文件时(无论是添加,删除还是更改了内容),我想调用我创建的方法( [self methodName]
)这样我就可以用新文件的名称更新我的表视图。如何通知文件更改?我是否需要收听NSNotification(如果是,它是什么?)或者我是否必须手动检查?谢谢。
When a file is changed in iCloud (whether added, deleted, or the content changed), I would like to call a method I created ([self methodName]
) so that I can update my table view with the names of the new files. How am I notified of the file change? Do I need to listen for a NSNotification (if so, what is it?) or do I have to check manually? Thanks.
推荐答案
我要监听的NSNotification的名称是 NSMetadataQueryDidUpdateNotification
。我就这样做了:
The name of the NSNotification I have to listen for is NSMetadataQueryDidUpdateNotification
. This is how I did it:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(queryDidUpdate:) name:NSMetadataQueryDidUpdateNotification object:query];
...
-(void)queryDidUpdate:(NSNotification *)notification {
//something changed, reload (NSMetadataQuery, create NSPredicate, rerun the query, etc.)
}
这篇关于如何检测iCloud中文件的更改时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文