【发布时间】:2020-01-06 20:01:48
【问题描述】:
我正在尝试在我的应用的 iCloud 通用容器中下载一个目录,我想在下载完成后调用一个函数。我可以得到这样的状态:
func synciCloud(){
do { try FileManager.default.startDownloadingUbiquitousItem(at: documentsPath)
do {
let status = try documentsPath.resourceValues(forKeys: [.ubiquitousItemDownloadingStatusKey])
print(status)
}
catch let error { print("Failed to get status: \(error.localizedDescription)") }
}
catch let error { print("Failed to download iCloud Documnets Folder: \(error.localizedDescription)") }
}
控制台打印:
URLResourceValues(_values: [__C.NSURLResourceKey(_rawValue: NSURLUbiquitousItemDownloadingStatusKey): NSURLUbiquitousItemDownloadingStatusCurrent],_keys: 设置([__C.NSURLResourceKey(_rawValue: NSURLUbiquitousItemDownloadingStatusKey)]))
我很困惑的是 NSMetadata 的语法以及如何执行我的函数。我的第一个想法是做类似下面代码的事情,但我不知道该怎么做:
if status.ubiquitousItemDownloadingStatus == ???? { function() }
任何建议将不胜感激。
谢谢。
【问题讨论】:
标签: swift icloud nsfilemanager