【问题标题】:How to get file paths for current open documents in a macOS project in Swift?如何在 Swift 的 macOS 项目中获取当前打开文档的文件路径?
【发布时间】:2017-06-24 10:11:13
【问题描述】:

我在 Swift 中有一个 macOS 项目,我想在其中获取当前打开文档的文件路径。如何实现?

编辑:我的意思是应用程序本身的打开文档。通常表示为窗口或选项卡。

PS 我检查了这些问题,但没有帮助: How to get file path? Loading documents in Document based app Cocoa question: How to get file path for current open document for the front most application

【问题讨论】:

    标签: swift cocoa nsdocument


    【解决方案1】:

    您可以从NSDocumentController 获取文档以及每个文档的 URL。

    for document in NSDocumentController.shared().documents {
        print("\(document.fileURL)")
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多