Class

NSSavePanel

A panel that prompts the user for information about where to save a file.

Declaration

@interface NSSavePanel : NSPanel

Overview

The Save panel provides an interface for specifying the location to save a file and the name of that file. You present this panel when the user attempts to save a new document, or when the user saves a copy of an existing document to a new location. The panel includes UI for browsing the file system, selecting a directory, and specifying the new name for the file. You can also add custom UI for your app using an accessory view.

An NSSavePanel object reports user interactions to its associated delegate object, which must adopt the NSOpenSavePanelDelegate protocol. Use your delegate object to validate the user's selection and respond to user interactions with the panel.

In macOS 10.15, the system always displays the Save dialog in a separate process, regardless of whether the app is sandboxed. When the user saves the document, macOS adds the saved file to the app's sandbox (if necessary) so that the app can write to the file. Prior to macOS 10.15, the system used a separate process only for sandboxed apps.

Topics

Creating a Save Panel

+ savePanel

Creates a new Save panel and initializes it with default information.

Responding to User Interactions

delegate

A custom object you use to manage interactions with an open or save panel.

NSOpenSavePanelDelegate

A set of methods for managing interactions with an open or save panel.

Showing the Panel

- beginSheetModalForWindow:completionHandler:

Presents the panel as a sheet modal to the specified window.

- beginWithCompletionHandler:

Presents the panel as a modeless window.

- runModal

Displays the panel and begins its event loop with the current working (or last-selected) directory as the default starting point.

- validateVisibleColumns

Validates and reloads the browser columns visible in the panel.

Getting the Selected Item

URL

A URL that contains the fully specified location of the targeted file.

Configuring the Panel's Appearance

title

The title of the panel.

prompt

The text to display in the default button.

message

The message text displayed in the panel.

nameFieldLabel

The label text displayed in front of the filename text field.

nameFieldStringValue

The user-editable filename currently shown in the name field.

directoryURL

The current directory shown in the panel.

accessoryView

The custom accessory view for the current app.

showsTagField

A Boolean value that indicates whether the panel displays the Tags field.

tagNames

The tag names that you want to include on a saved file.

Configuring the Panel's Behavior

canCreateDirectories

A Boolean value that indicates whether the panel displays UI for creating directories.

canSelectHiddenExtension

A Boolean value that indicates whether the panel displays UI for hiding or showing filename extensions.

showsHiddenFiles

A Boolean value that indicates whether the panel displays files that are normally hidden from the user.

extensionHidden

A Boolean value that indicates whether the extension-hiding checkbox is visible and checked.

expanded

A Boolean value that indicates whether whether the panel is expanded.

Button tags

Button tags that refer to items on the panel.

Configuring the File Types

allowedFileTypes

An array of filename extensions or UTIs that represent the allowed file types for the panel.

allowsOtherFileTypes

A Boolean value that indicates whether the panel allows the user to save files with a filename extension that’s not in the list of allowed types.

treatsFilePackagesAsDirectories

A Boolean value that indicates whether the panel displays file packages as directories.

NSSavePanelAuxiliaryOpaque

A private data structure used internally by the Save panel.

Handling Actions

- ok:

The action method that the panel calls when the user clicks the OK button.

- cancel:

The action method that the panel calls when the user clicks the Cancel button.

Deprecated

Avoid using deprecated classes and protocols in your apps.

Deprecated Symbols

Review unsupported symbols and their replacements.

Relationships

Inherits From

See Also

Open and Save Panels

NSOpenPanel

A panel that prompts the user to select a file to open.

NSOpenSavePanelDelegate

A set of methods for managing interactions with an open or save panel.