Save Panel 存储面板 macos
The standard Mac dialog for naming a file and choosing where to save it
Mac 上给文件起名、选择存储位置的标准对话框
标本可交互 —— 点点看。Specimen is live — try it.
Anatomy — every part, named解剖 —— 每个部件的名字
-
1 Name field名称栏
NSSavePanel.nameFieldStringValueThe editable Save As text box is the panel's name field.
「存储为」那个可编辑文本框就是面板的名称栏。
Prompt fragmentPrompt 片段the save panel's name field (NSSavePanel.nameFieldStringValue): the editable filename box above the browser
存储面板的名称栏(NSSavePanel.nameFieldStringValue):浏览器上方可编辑的文件名输入框
-
2 Disclosure expansion button披露展开按钮
NSSavePanel.isExpanded“The little arrow that makes the save window bigger” is the disclosure button for the panel's expanded browser.
「让保存窗口变大的那个小箭头」就是展开面板浏览器的披露按钮。
Prompt fragmentPrompt 片段the save panel's disclosure expansion button (NSSavePanel.isExpanded): the small control that reveals or hides the full file browser
存储面板的披露展开按钮(NSSavePanel.isExpanded):显示或隐藏完整文件浏览器的小控件
-
3 Format pop-up格式弹出式按钮
NSSavePanel.allowedContentTypesThe file-type selector beneath the name is the format pop-up, constrained by the panel's allowed content types.
名称下方的文件类型选择器就是格式弹出式按钮,可选范围受面板允许的内容类型约束。
Prompt fragmentPrompt 片段the save panel's format pop-up (NSSavePanel.allowedContentTypes): the native file-type selector beneath the filename field
存储面板的格式弹出式按钮(NSSavePanel.allowedContentTypes):文件名输入框下方的原生文件类型选择器
Prompt — paste into your agentPrompt —— 直接粘贴给你的代理
Present the standard Save Panel with NSSavePanel (SwiftUI workflow: View.fileExporter), including its editable name field, disclosure button for the expanded file browser, allowed-content-type format pop-up, and Finder-style sidebar. Do not rebuild the system save dialog from custom controls.
用 NSSavePanel 弹出标准存储面板(SwiftUI 流程:View.fileExporter),包括可编辑的名称栏、展开文件浏览器的披露按钮、按允许内容类型过滤的格式弹出式按钮,以及 Finder 风格的边栏。不要用自定义控件重造系统保存对话框。
Debug prompt — when it misbehaves调试 Prompt —— 当它不听话时
Debug my macOS save panel (NSSavePanel, NSOpenPanel). Rule out: sandboxed URLs failing later because startAccessingSecurityScopedResource was never called or a bookmark was never saved; allowedContentTypes filtering out everything so Save stays disabled; runModal blocking the app when beginSheetModal was intended; the panel opening in the wrong folder because directoryURL is set after presentation. The symptom:
调试我的 macOS 存储面板(NSSavePanel、NSOpenPanel)。排除以下可能:沙盒 URL 之后失效,因为从没调用 startAccessingSecurityScopedResource,或从没保存 bookmark;allowedContentTypes 把所有类型都过滤掉了,导致「存储」按钮一直不可用;本该用 beginSheetModal 却用了 runModal 卡住整个应用;因为在展示之后才设 directoryURL,面板打开在错误的文件夹。症状是:
In code代码里叫什么
| Framework框架 | Symbol符号 | Note说明 |
|---|---|---|
| AppKit | NSSavePanel | |
| SwiftUI | View.fileExporter(isPresented:document:contentType:defaultFilename:onCompletion:) | |
| AppKit | NSSavePanel.beginSheetModal(for:completionHandler:) |