如何检测iCloud中文件的更改时间?

Jac*_*ies 5 iphone objective-c ipad ios icloud

当在iCloud中更改文件(无论是添加,删除还是更改内容)时,我想调用我创建的方法([self methodName]),以便我可以使用新文件的名称更新我的表视图.如何通知文件更改?我是否需要收听NSNotification(如果是,它是什么?)或者我是否必须手动检查?谢谢.

Jac*_*ies 6

我必须听的NSNotification的名字是NSMetadataQueryDidUpdateNotification.我就这样做了:

[[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.)

}
Run Code Online (Sandbox Code Playgroud)