# NSSavePanel

jagapen@smithlab.chem.wisc.edu
n.pero@mi.flashnet.it
mirko.viviani@rccr.cremona.it
Generated at 2026-06-27 19:09:52 +0000

Standard panel for saving files

1999, 2000 Free Software Foundation, Inc.
Software documentation for the NSSavePanel class
AppKit/NSSavePanel.h

Implements a panel that allows the user to save a file.

There is only one save panel per application and this panel is obtained by calling the +savePanel class method. From here, you should set the required file extension using -setRequiredFileType: When ready to show the panel, use the -runModal , or a similar method to show the panel in a modal session. Other methods allow you to set the initial directory and initially choosen file. The method will return one of NSOKButton or NSCancelButton depending on which button the user pressed.

Use the -filename method to retrieve the name of the file the user choose.

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
savePanel

Creates (if needed) and returns the shared NSSavePanel instance.

URL
Description forthcoming.
accessoryView

Returns the accesory view (if any).

See Also: -setAccessoryView:

allowedFileTypes

Returns an array of the allowed file types. The default, indicated by `nil`, is any file type is allowed.

See Also: -setAllowedFileTypes:

allowsOtherFileTypes
Description forthcoming.
beginSheetForDirectory:
path
file:
filename
modalForWindow:
docWindow
modalDelegate:
delegate
didEndSelector:
didEndSelector
contextInfo:
contextInfo
Description forthcoming.
beginSheetModalForWindow:
window
completionHandler:
handler
Description forthcoming.
beginWithCompletionHandler:
handler
Description forthcoming.
canCreateDirectories
Description forthcoming.
canSelectHiddenExtension
Description forthcoming.
cancel:
sender

Invoked by the 'Cancel' button. Saves the current directory browsed and stop the modal event loop using [NSApplication -stopModalWithCode:]

See Also: -ok:

directory

Returns the directory choosen by the user. Do not invoke directory within a modal loop because the information that these methods fetch is updated only upon return.

See Also: -setDirectory:

directoryURL
Description forthcoming.
filename

Returns the absolute filename choosen by the user. Do not invoke filename within a modal loop because the information that these methods fetch is updated only upon return.

isExpanded
Description forthcoming.
isExtensionHidden
Description forthcoming.
message
Description forthcoming.
nameFieldLabel
Description forthcoming.
nameFieldStringValue
Description forthcoming.
ok:
sender

Invoked by the "OK" button.

See Also: -cancel:

prompt

Returns the prompt used in the current path field.

See Also: -setPrompt:

requiredFileType

Returns the required file type. The default, indicated by an empty string, is no required file type.

This method is equivalent to calling -allowedFileTypes and returning the first element of the list of allowed types, or the empty string if there are none.

See Also: -setRequiredFileType:

runModal

Shows the save panel for the user. This method invokes -runModalForDirectory:file: with empty strings for the filename. Returns NSOKButton (if the user clicks the OK button) or NSCancelButton (if the user clicks the Cancel button).

See Also: -runModalForDirectory:file:

runModalForDirectory:
path
file:
filename

Initializes the panel to the directory specified by path and, optionally, the file specified by filename, then displays it and begins its modal event loop; path and filename can be empty strings. The method invokes [NSApplication:-runModalForWindow:] method with self as the argument. Returns NSOKButton (if the user clicks the OK button) or NSCancelButton (if the user clicks the Cancel button). If path is `nil` then the panel displays the last selected directory or as a last resort, the current working directory.

See Also: -runModal

runModalForDirectory:
path
file:
filename
relativeToWindow:
window
Description forthcoming.
selectText:
sender
Description forthcoming.
setAccessoryView:
aView

Sets an accessory view which is shown near the bottom of the panel. The panel is automatically expanded with enough room to show the extra view. You can use this extra view to customize various characteristics of the file selection mechanism. For instance you could add a popup button which allows the user to select the format that the file is saved in (e.g. rtf or txt). See also -validateVisibleColumns .

See Also: -accessoryView

setAllowedFileTypes:
types

Specifies the allowed types, i.e., file name extensions to be appended to any selected files that don't already have one of those extensions. The elements of the array should be strings that do not include the period that begins the extension. Invoke this method each time the Save panel is used for another file type within the application. If you do not invoke it, or set it to an empty array or `nil`, no extension will be appended, indicated by `nil` returned from -allowedFileTypes .

See Also: -allowedFileTypes

setAllowsOtherFileTypes:
flag
Description forthcoming.
setCanCreateDirectories:
flag
Description forthcoming.
setCanSelectHiddenExtension:
flag
Description forthcoming.
setDirectory:
path

Sets the current path name in the Save panel's browser. The path argument must be an absolute path name.

See Also: -directory

setDirectoryURL:
url

Sets the current path name in the Save panel's browser. The path argument must be an absolute path name.

See Also: -directory

setExtensionHidden:
flag
Description forthcoming.
setMessage:
message
Description forthcoming.
setNameFieldLabel:
label
Description forthcoming.
setNameFieldStringValue:
value
Description forthcoming.
setPrompt:
prompt

Returns the prompt of the Save panel field that holds the current pathname or file name. By default this prompt is 'Name: '.

See Also: -prompt

setRequiredFileType:
fileType

Specifies the type, a file name extension to be appended to any selected files that don't already have that extension; The argument type should not include the period that begins the extension. Invoke this method each time the Save panel is used for another file type within the application. If you do not invoke it, or set it to empty string or `nil`, no extension will be appended, indicated by an empty string returned from -requiredFileType .

This method is equivalent to calling -setAllowedFileTypes: with an array containing only fileType.

See Also: -requiredFileType

setShowsHiddenFiles:
flag
Description forthcoming.
setTitle:
title

Sets the title of the NSSavePanel to title. By default, 'Save' is the title string. If you adapt the NSSavePanel for other uses, its title should reflect the user action that brings it to the screen.

See Also: -title

setTreatsFilePackagesAsDirectories:
flag

Sets the NSSavePanel's behavior for displaying file packages (for example, MyApp.app) to the user. If flag is `YES`, the user is shown files and subdirectories within a file package. If `NO`, the NSSavePanel shows each file package as a file, thereby giving no indication that it is a directory.

See Also: -treatsFilePackagesAsDirectories

showsHiddenFiles
Description forthcoming.
title

Returns the title of the save panel

See Also: -setTitle:

treatsFilePackagesAsDirectories
Returns `YES` if file packages are shown as directories. The default is `NO`.
validateVisibleColumns

Validates and possibly reloads the browser columns that are visible in the Save panel by causing the delegate method -panel:shouldShowFilename: to be invoked. One situation in which this method would find use is whey you want the browser to show only files with certain extensions based on the selection made in an accessory-view pop-up list. When the user changes the selection, you would invoke this method to revalidate the visible columns.

Software documentation for the NSObject(NSOpenSavePanelDelegate) informal protocol
AppKit/NSSavePanel.h
Description forthcoming.
panel:
sender
compareFilename:
name1
with:
name2
caseSensitive:
caseSensitive
Description forthcoming.
panel:
sender
didChangeToDirectoryURL:
url
Description forthcoming.
panel:
sender
directoryDidChange:
path
Description forthcoming.
panel:
sender
isValidFilename:
filename
Description forthcoming.
panel:
sender
shouldEnableURL:
url
Description forthcoming.
panel:
sender
shouldShowFilename:
filename
Description forthcoming.
panel:
sender
userEnteredFilename:
filename
confirmed:
flag
Description forthcoming.
panel:
sender
validateURL:
url
error:
error
Description forthcoming.
panel:
sender
willExpand:
expand
Description forthcoming.
panelSelectionDidChange:
sender
Description forthcoming.
Software documentation for the NSObject(NSSavePanelDelegate) informal protocol
AppKit/NSSavePanel.h
Description forthcoming.
panel:
sender
compareFilename:
filename1
with:
filename2
caseSensitive:
caseSensitive
Description forthcoming.
panel:
sender
directoryDidChange:
path
Description forthcoming.
panel:
sender
isValidFilename:
filename
The NSSavePanel sends this message just before the end of a modal session for each file name displayed or selected (including file names in multiple selections). The delegate determines whether it wants the file identified by filename; it returns `YES` if the file name is valid, or `NO` if the NSSavePanel should stay in its modal loop and wait for the user to type in or select a different file name or names. If the delegate refuses a file name in a multiple selection, none of the file names in the selection are accepted.
panel:
sender
shouldShowFilename:
filename
Sent by NSSavePanel to check whether a file should be displayed in the panel or not. The filename argument is the complete path to the file.
panel:
sender
userEnteredFilename:
fileName
confirmed:
okFlag
Description forthcoming.
panel:
sender
willExpand:
expanding
Description forthcoming.
panelSelectionDidChange:
sender
Description forthcoming.
Software documentation for the NSOpenSavePanelDelegate protocol
AppKit/NSSavePanel.h
NSObject
Description forthcoming.