问题描述
我正在使用NSMetadataQuery在无处不在的容器中查询iCloud上的文件。该代码在iOS13.7上可以正常工作,但在iOS14上不起作用。在iOS 14上,没有通知发送到该应用。这是我的代码的已知错误还是实现问题?
谢谢
var m_basename = "textfile.txt"
override func viewDidLoad() {
super.viewDidLoad()
// check for iCloud
if !ViewController.checkForICloud() {
fatalError("iCloud not configured")
}
// Now configure the meta data query
m_textFileQuery.searchScopes = [NSMetadataQueryUbiquitousDocumentsScope]
m_textFileQuery.predicate = NSPredicate(format: "%K LIKE '\(m_basename)'",NSMetadataItemFSNameKey)
m_textFileQuery.start()
NotificationCenter.default.addObserver( self,selector:#selector(textFileQueryDidUpdate),name:NSNotification.Name.NSMetadataQueryDidFinishGathering,object:m_textFileQuery)
NotificationCenter.default.addObserver( self,name:NSNotification.Name.NSMetadataQueryDidUpdate,object:m_textFileQuery)
}
@objc func textFileQueryDidUpdate(notification: NSNotification) {
print(#function,"textFile query found \(m_textFileQuery.resultCount) file(s)")
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)