如何在基于文档的应用程序中隐藏打开和保存文档功能?

How to hide Open and Save document features in a Document Based application?

与 Safari 应用程序一样,在 macOS Swift 项目中,我想让用户打开多个 window 并可能使用选项卡式浏览从 window 切换到另一个.该应用程序以空白 window 开头,不需要保存或打开文档。

基于文档的应用程序对我来说似乎非常适合处理 window,但我不希望用户必须处理文档。如果可能,如何禁用或隐藏打开和保存文档功能?

编辑:如果可能的话,我也想禁用此弹出窗口:

非常简单 - 只需从菜单 XIB 中删除(删除)Open、Open Recent...、Save、Save as... 菜单项。如果您不想要标题栏,只需取消选中 XIB 中 window 的 "Title" 复选框,尽管这会使 window 难以移动。

如果您有标题栏,要覆盖 "Untitled",您可以

override var displayName: String! {
    get {
        return "Anything you like, even \"\""
    }
    set {

    }
}

然而,这仍然允许通过人字形访问另存为菜单。要抑制它,你需要一个 NSWindowDelegate Docs

window(_:shouldPopUpDocumentPathMenu:) Asks the delegate whether the window displays the title pop-up menu in response to a Command-click or Control-click on its title.

只需将 autosavesInPlace 添加为 true