Class

NSSavePanel

A Save panel that you can run in a modal loop.

Declaration

@interface NSSavePanel : NSPanel

Overview

The Save panel provides a simple way for a user to specify a file to use when saving a document or other data. It can restrict the user to files of a certain type, as specified by an extension. An NSSavePanel object manages a panel that allows users to specify the directory and name under which a file is saved. It supports browsing of the file system, and it accommodates custom accessory views.

An NSSavePanel object may have a delegate. The methods that NSSavePanel delegates may implement are specified by the NSOpenSavePanelDelegate protocol.

In a sandboxed app, when a user saves a document, the Save dialog is presented by the powerbox, not AppKit. macOS then adds the saved file to the app’s sandbox (if necessary) to allow the app to write to the file.

Topics

Creating Panels

+ savePanel

Returns a Save panel that has been initialized with default values.

Configuring Panels

accessoryView

The custom accessory view for the current application.

title

The title of the panel.

prompt

The prompt of the default button.

nameFieldLabel

The string displayed in front of the filename text field.

message

The message text displayed in the save panel.

canCreateDirectories

A Boolean value that indicates whether the panel allows the user to create directories.

showsHiddenFiles

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

delegate

The panel’s delegate.

showsTagField

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

tagNames

The tag names to set on the file the user has saved.

Configuring Panel Content

extensionHidden

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

- requiredFileType

Returns the required file type (if any).

Deprecated
- setRequiredFileType:

Specifies the file type (as an extension) or a UTI.

Deprecated
directoryURL

The directory shown in the panel as a URL.

- setDirectory:

Sets the current pathname in the panel’s browser.

Deprecated
canSelectHiddenExtension

A Boolean value that indicates whether the panel allows the user to hide or show file extensions.

allowedFileTypes

An array of NSString objects specifying the allowed file types for the panel.

allowsOtherFileTypes

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

treatsFilePackagesAsDirectories

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

Running Panels

- beginSheetForDirectory:file:modalForWindow:modalDelegate:didEndSelector:contextInfo:

Presents a Save panel as a sheet with a specified path and, optionally, a specified file in that path.

Deprecated
- 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.

- runModalForDirectory:file:

Initializes the panel to the directory and file specified, if any, then displays it and begins its modal event loop.

Deprecated
- panel:compareFilename:with:caseSensitive:

Controls the ordering of files presented by the NSSavePanel object specified.

Deprecated
- panel:isValidFilename:

Gives the delegate the opportunity to validate selected items.

Deprecated
- validateVisibleColumns

Validates and possibly reloads the browser columns visible in the panel by invoking the delegate method panel:shouldShowFilename:.

- panel:shouldShowFilename:

Gives the delegate the opportunity to filter items that it doesn’t want the user to choose.

Deprecated
- panel:directoryDidChange:

Tells the delegate that the user has changed the selected directory in the NSSavePanel object specified.

Deprecated

Accessing User Selection

- directory

Returns the absolute pathname of the directory currently shown in the panel.

Deprecated
- filename

Returns the absolute pathname of the file currently shown in the panel.

Deprecated
URL

The absolute pathname of the file currently shown in the panel as a URL.

expanded

A Boolean value that indicates whether the panel is expanded.

nameFieldStringValue

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

- selectText:

This method has been deprecated.

Deprecated

Handling Actions

- ok:

This action method is invoked when the user clicks the panel’s OK button.

- cancel:

This action method is invoked when the user clicks the panel’s Cancel button.

Constants

Button tags

Button tags that refer to items on the panel.

NSSavePanelAuxiliaryOpaque

A private data structure used internally by NSSavePanel.

Relationships

Inherits From

See Also

Open and Save Panels

NSOpenPanel

The Open panel for the Cocoa user interface.

NSOpenSavePanelDelegate

A set of methods that a delegate of NSOpenPanel or NSSavePanel should implement.