【问题标题】:Incorrect method suggestion by XcodeXcode 的方法建议不正确
【发布时间】:2018-05-01 05:01:27
【问题描述】:

我正在尝试在我的 OS X 应用程序中创建一个目录。当我开始打字时,建议使用该方法。但该方法似乎被错误地建议。 NSFileManger 中方法的 attributes 参数通常采用 [FileAttributeKey:Any] 字典,但这里在建议中采用 [String:Any] 库。

我检查了 NSFileManager API,但找不到任何类似的 API。谁能解释这里发生了什么?

【问题讨论】:

  • 你必须像 FileManager.default.create 一样使用它.....而不是像 FileManager.create 那样直接使用
  • @UmarFarooque .. 我知道.. 这里使用的 fileManager 定义为 let fileManager = FileManager.default
  • 尝试导入移动核心服务,然后将密钥传递到属性字典中。
  • 很可能是签名中的占位符还没有正确更新,还需要传递[FileAttributeKey:Any]?作为属性。
  • @holex .. 我尝试传递 [FileAttributeKey:Any]?。但出现以下错误无法将类型“[FileAttributeKey:Date]”的值转换为预期的参数类型“[String:Any]?”

标签: swift xcode macos nsfilemanager


【解决方案1】:

您的部署目标或 Xcode 版本过旧。 FileAttributeKey 是新的。

https://developer.apple.com/documentation/foundation/fileattributekey

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-23
    • 2015-01-27
    • 2021-06-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多