iCloud文件下载状态使用ubiquitousItemDownloadingStatusKey不起作用。

huangapple go评论66阅读模式
英文:

iCloud file download status using ubiquitousItemDownloadingStatusKey not working

问题

如果尝试使用 resourceValues(forKeys:) 检查 URL 的下载状态,您的代码如下:

if let status = try? url.resourceValues(forKeys: [URLResourceKey.ubiquitousItemDownloadingStatusKey]) {
 if status.ubiquitousItemDownloadingStatusKey == .current {
  print("File download complete.")
 }
}

这段代码之前可以正常工作,但现在 Xcode 报错:“Value of type 'URLResourceValues' has no member 'ubiquitousItemDownloadingStatusKey'”,并且我只能从 status 中获取一些 thumbnailDictionary。有人可以告诉我这里发生了什么吗?我是否犯了一些愚蠢的错误?

英文:

I am trying to check the download status of my url using resourceValues(forKeys:). This is my code

if let status = try? url.resourceValues(forKeys: [URLResourceKey.ubiquitousItemDownloadingStatusKey]) {
 if status.ubiquitousItemDownloadingStatusKey == .current {
  print("File download complete.")
 }
}

This code worked before but now Xcode says "Value of type 'URLResourceValues' has no member 'ubiquitousItemDownloadingStatusKey'" and all I am able to get from status is some thumbnailDictionary. Can anyone tell me what is happening here? Am I making some silly mistake ?

答案1

得分: 1

你在URLResourceValues上使用了错误的属性:

if let values = try? url.resourceValues(forKeys: [.ubiquitousItemDownloadingStatusKey]),
   let status = values.ubiquitousItemDownloadingStatus {
    if status == .current {
        print("文件下载完成。")
    }
}
英文:

You're using the wrong property on URLResourceValues:

if let values = try? url.resourceValues(forKeys: [.ubiquitousItemDownloadingStatusKey]),
   let status = values.ubiquitousItemDownloadingStatus {
    if status == .current {
        print("File download complete.")
    }
}

huangapple
  • 本文由 发表于 2023年2月24日 15:26:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/75553644.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定