Mac Developer Library

Developer

AppKit Framework Reference NSSavePanel Class Reference

Options
Deployment Target:

On This Page
Language:

NSSavePanel

An NSSavePanel object creates and manages a Save panel and allows you to run the panel in a modal loop. 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. More...

Import Statement


import AppKit @import AppKit;

Availability


Available in OS X v10.0 and later.
  • Returns a Save panel that has been initialized with default values.

    Declaration

    Objective-C

    + (NSSavePanel *)savePanel

    Return Value

    The initialized Save panel.

    Import Statement

    Availability

    Available in OS X v10.0 and later.

  • Returns the custom accessory view for the current application.

    Declaration

    Swift

    var accessoryView: NSView?

    Objective-C

    @property(strong) NSView *accessoryView

    Return Value

    The custom accessory view for the current application.

    Discussion

    The panel relinquishes ownership of the accessory view after the panel is closed. If you want to reuse the accessory view, you should not rely on the panel to hold onto the accessory view until the next time you use it; instead, you should maintain your own strong reference to the view.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Customizes the panel for the application by adding a custom view to the panel.

    Declaration

    Swift

    var accessoryView: NSView?

    Objective-C

    @property(strong) NSView *accessoryView

    Parameters

    aView

    View to set as the panel’s accessory view.

    Discussion

    The custom object that is added appears just above the OK and Cancel buttons at the bottom of the panel. The NSSavePanel object automatically resizes itself to accommodate aView. You can invoke this method repeatedly to change the accessory view as needed. If aView is nil, the Save panel removes the current accessory view.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the title of the panel.

    Declaration

    Swift

    var title: String?

    Objective-C

    @property(copy) NSString *title

    Return Value

    The title of the panel.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    – setTitle:

  • Sets the title of the panel.

    Declaration

    Swift

    var title: String?

    Objective-C

    @property(copy) NSString *title

    Parameters

    title

    String to set as the panel’s title.

    Discussion

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

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    – title

  • Returns the prompt of the default button.

    Declaration

    Swift

    var prompt: String?

    Objective-C

    @property(copy) NSString *prompt

    Return Value

    The prompt of the default button.

    Discussion

    This prompt appears on all NSSavePanel objects (or all NSOpenPanel objects if the receiver of this message is an NSOpenPanel instance) in your application. By default, the text in the default button is “Open” for an open panel and “Save” for a Save panel.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    – setPrompt:

  • Sets the prompt of the default button.

    Declaration

    Swift

    var prompt: String?

    Objective-C

    @property(copy) NSString *prompt

    Parameters

    prompt

    String to set as the prompt of the panel’s default button.

    Discussion

    This prompt appears on all NSSavePanel objects (or all NSOpenPanel objects if the receiver of this message is an NSOpenPanel instance) in your application. By default, the text in the default button is “Open” for an Open panel and “Save” for a Save panel.

    It is intended that short words or phrases, such as “Open,” “Save,” “Set,” or “Choose,” be used on the button. The button is not resized to accommodate long prompts.

    Since this method previously affected a title field, any colon at the end of prompt is removed.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    – prompt

  • Returns the string displayed in front of the filename text field.

    Declaration

    Swift

    var nameFieldLabel: String?

    Objective-C

    @property(copy) NSString *nameFieldLabel

    Return Value

    The string displayed in front of the filename text field.

    Discussion

    By default the label is “Save As:”.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.3 and later.

  • Sets the text displayed in front of the text field.

    Declaration

    Swift

    var nameFieldLabel: String?

    Objective-C

    @property(copy) NSString *nameFieldLabel

    Parameters

    label

    String to set as the text displayed in front of the panel’s text field.

    Discussion

    By default the label is “Save As:”.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.3 and later.

  • Returns the message displayed in the save panel.

    Declaration

    Swift

    var message: String?

    Objective-C

    @property(copy) NSString *message

    Return Value

    The message displayed in the save panel.

    Discussion

    This prompt appears on all NSSavePanel objects (or all NSOpenPanel objects if the receiver of this message is an NSOpenPanel instance) in your application. The default message text is an empty string.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.3 and later.

    See Also

    – setMessage:

  • Sets the message text displayed in the panel.

    Declaration

    Swift

    var message: String?

    Objective-C

    @property(copy) NSString *message

    Parameters

    message

    String to set as the panel’s message.

    Discussion

    This prompt appears on all NSSavePanel objects (or all NSOpenPanel objects if the receiver of this message is an NSOpenPanel instance) in your application. The default message text is an empty string.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.3 and later.

    See Also

    – message

  • Returns a Boolean value that indicates whether the panel allows the user to create directories.

    Declaration

    Swift

    var canCreateDirectories: Bool

    Objective-C

    @property BOOL canCreateDirectories

    Return Value

    YEStrue when the panel allows the user to create directories; otherwise, NOfalse.

    Discussion

    The default value is YEStrue.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.3 and later.

  • Sets whether the panel allows the user to create directories.

    Declaration

    Swift

    var canCreateDirectories: Bool

    Objective-C

    @property BOOL canCreateDirectories

    Parameters

    flag

    If YEStrue, the panel allows the user to create directories; if NOfalse, the panel does not.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.3 and later.

  • Returns whether the panel displays files that are normally hidden from the user.

    Declaration

    Swift

    var showsHiddenFiles: Bool

    Objective-C

    @property BOOL showsHiddenFiles

    Return Value

    YEStrue if the panel displays hidden files; otherwise, NOfalse.

    Discussion

    The default value is NOfalse.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • Specifies whether the panel displays files that are normally hidden from the user.

    Declaration

    Swift

    var showsHiddenFiles: Bool

    Objective-C

    @property BOOL showsHiddenFiles

    Parameters

    flag

    If YEStrue, the panel displays hidden files; if NOfalse, it does not.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • Returns the panel’s delegate.

    Declaration

    Swift

    unowned(unsafe) var delegate: NSOpenSavePanelDelegate?

    Objective-C

    @property(assign) id<NSOpenSavePanelDelegate> delegate

    Return Value

    The panel’s delegate.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.3 and later.

  • Sets an object as the panel’s delegate, after verifying which delegate methods are implemented.

    Declaration

    Swift

    unowned(unsafe) var delegate: NSOpenSavePanelDelegate?

    Objective-C

    @property(assign) id<NSOpenSavePanelDelegate> delegate

    Parameters

    anObject

    Object to set as the panel’s delegate.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    – delegate

  • Returns a Boolean value that indicates whether the panel displays the Tags field.

    Declaration

    Swift

    var showsTagField: Bool

    Objective-C

    @property BOOL showsTagField

    Return Value

    YEStrue when the panel displays the Tags field; otherwise, NOfalse. (The Tags field is appropriate only in a Save panel.)

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.9 and later.

  • Sets whether the panel displays the Tags field.

    Declaration

    Swift

    var showsTagField: Bool

    Objective-C

    @property BOOL showsTagField

    Parameters

    flag

    If YEStrue, the panel displays the Tags field; if NOfalse, the panel doesn’t display the Tags field.

    Discussion

    If you pass YEStrue to this method, you are responsible for setting tag names on the resulting file after saving is complete. It’s recommended that you invoke this method directly and either set tag names or opt out of tagging altogether. If this method is never invoked, OS X will automatically show the tag field and attempt to apply the tags to the file. (To set tags on files, use the NSURLTagNamesKey, described in Common File System Resource Keys.)

    Note that the Tags field is appropriate only in a Save panel.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.9 and later.

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

    Declaration

    Swift

    var tagNames: [AnyObject]?

    Objective-C

    @property(copy) NSArray *tagNames

    Discussion

    If showsTagField returns YEStrue, this method returns a non-nil array, regardless of whether the array is empty; if showsTagField returns NOfalse, this method returns nil. Note that the Tags field is appropriate only in a Save panel.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.9 and later.

  • Specifies the initial tag names that should be displayed in the panel.

    Declaration

    Swift

    var tagNames: [AnyObject]?

    Objective-C

    @property(copy) NSArray *tagNames

    Parameters

    tagNames

    An array of strings that represent the inital set of tag names to display in the panel. If nil or an empty array, no initial tag names are displayed in the panel.

    Discussion

    When showsTagField returns YEStrue, use this method to set initial tag names to be displayed prior to displaying the receiver. Note that the Tags field is appropriate only in a Save panel.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.9 and later.

  • isExtensionHidden isExtensionHidden Available in OS X v10.1 through OS X v10.9

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

    Declaration

    Objective-C

    - (BOOL)isExtensionHidden

    Return Value

    YEStrue when the extension-hiding checkbox is visible and checked; otherwise, NOfalse.

    Import Statement

    Availability

    Available in OS X v10.1 through OS X v10.9.

  • Sets the value of the extension-hiding checkbox.

    Declaration

    Swift

    var extensionHidden: Bool

    Objective-C

    @property(getter=isExtensionHidden) BOOL extensionHidden

    Parameters

    flag

    If YEStrue, the extension-hiding checkbox is visible and checked; if NOfalse, it is not.

    Discussion

    This method should rarely be used because the state is saved on a per-application basis. Use this method to set whether a file’s extension should be indicated as being shown.

    This method has no effect if the user has chosen to show all file extensions in Finder.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.1 and later.

  • Returns the required file type (if any).

    Deprecation Statement

    Use allowedFileTypes instead.

    Declaration

    Objective-C

    - (NSString *)requiredFileType

    Return Value

    The required file type (if any).

    Discussion

    A file specified in the Save panel is saved with the designated filename and this file type as an extension. Examples of common file types are “rtf”, “tiff”, and “ps”. File type strings encoding HFS file types are not valid values for this attribute. An nil return value indicates that the user can save to any ASCII file.

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

    Import Statement

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.6.

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

    Deprecation Statement

    Use setAllowedFileTypes: instead.

    Declaration

    Objective-C

    - (void)setRequiredFileType:(NSString *)type

    Parameters

    type

    String to set as the extension to be appended to any selected files that don’t already have that extension.

    Discussion

    If type is an extension, it should not include the period that begins the extension. Pass nil to indicate any type. File type strings encoding HFS file types are not valid values for this attribute. You need to invoke this method each time the Save panel is used for another file type within the application.

    This method is equivalent to calling setAllowedFileTypes: with an array containing only type (unless type is nil, and then it’s equivalent to calling setAllowedFileTypes: with nil).

    Import Statement

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.6.

  • Sets the directory shown in the panel to the directory with the specified URL.

    Declaration

    Swift

    @NSCopying var directoryURL: NSURL?

    Objective-C

    @property(copy) NSURL *directoryURL

    Parameters

    url

    The URL of the directory to set.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • Sets the current pathname in the panel’s browser.

    Deprecation Statement

    Use setDirectoryURL: instead.

    Declaration

    Objective-C

    - (void)setDirectory:(NSString *)path

    Parameters

    path

    String to set as the panel’s current pathname.

    Discussion

    The path argument must be an absolute pathname.

    Import Statement

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.6.

  • Returns a Boolean value that indicates whether the panel allows the user to hide or show extensions.

    Declaration

    Swift

    var canSelectHiddenExtension: Bool

    Objective-C

    @property BOOL canSelectHiddenExtension

    Return Value

    YEStrue when the panel allows the user to hide or show extensions; otherwise, NOfalse.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.3 and later.

  • Sets whether the panel allows the user to hide or show extensions.

    Declaration

    Swift

    var canSelectHiddenExtension: Bool

    Objective-C

    @property BOOL canSelectHiddenExtension

    Parameters

    flag

    If YEStrue, the panel allows the user to hide or show extensions; if NOfalse, it does not.

    Discussion

    This method must be called before the panel is displayed. If set to YEStrue, isExtensionHidden and setExtensionHidden:, respectively, can be used to get and set the value of the checkbox that hides or shows extensions.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.1 and later.

  • Sets the filename in the name field to the specified value.

    Declaration

    Swift

    var nameFieldStringValue: String

    Objective-C

    @property(copy) NSString *nameFieldStringValue

    Parameters

    value

    The filename to set. The value must not be nil.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • Returns an array of the allowed file types.

    Declaration

    Swift

    var allowedFileTypes: [AnyObject]?

    Objective-C

    @property(copy) NSArray *allowedFileTypes

    Return Value

    An array of the allowed file types.

    Discussion

    For a full discussion, see setAllowedFileTypes:.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.3 and later.

  • Specifies the allowed file types for the panel.

    Declaration

    Swift

    var allowedFileTypes: [AnyObject]?

    Objective-C

    @property(copy) NSArray *allowedFileTypes

    Parameters

    types

    An array of NSString objects specifying the file types the user can save the file as. A nil value indicates that any file type can be used.

    If the array is not nil and the array contains no items, an exception is raised.

    Discussion

    A file type can be a common file extension, or a UTI. A nil value indicates that any file type can be used. The default value is nil.

    If no extension is given by the user, the first item in the allowedFileTypes will be used as the extension for the save panel. If the user specifies a type not in the array, and allowsOtherFileTypes is YEStrue, they will be presented with another dialog when prompted to save.

    NSOpenPanel: In versions of OS X less than v10.6, this property is ignored. For applications that link against v10.6 and higher, this property determines which files should be enabled in the open panel. Using the deprecated methods to show the open panel (the ones that take a types: parameter) will overwrite this value, and should not be used. The allowed file types can be changed while the panel is running (for example, from an accessory view). The file type can be a common file extension, or a UTI. This is also known as the “enabled file types.” A nil value indicates that all files should be enabled.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.3 and later.

  • Returns 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.

    Declaration

    Swift

    var allowsOtherFileTypes: Bool

    Objective-C

    @property BOOL allowsOtherFileTypes

    Return Value

    YEStrue if the panel allows the user to save files with an extension that’s not in the list of allowed types; otherwise, NOfalse.

    Discussion

    If the user tries to save a filename with a recognized extension that's not in the list of allowed types they are presented with a dialog. If this method returns YEStrue, then the dialog presents the option of using the extension the user specified.

    The default setting is NOfalse.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.3 and later.

  • Sets whether the panel allows the user to save files with an extension that’s not in the list of allowed types.

    Declaration

    Swift

    var allowsOtherFileTypes: Bool

    Objective-C

    @property BOOL allowsOtherFileTypes

    Parameters

    flag

    If YEStrue, the panel allows the user to save files with an extension that’s not in the list of allowed types; if NOfalse, it does not.

    Discussion

    If the user tries to save a filename with a recognized extension that's not in the list of allowed types they are presented with a dialog. If allowsOtherFileTypes is YEStrue, then the dialog presents the option of using the extension the user specified.

    The default setting is NOfalse.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.3 and later.

  • Returns a Boolean value that indicates whether the panel displays file packages as directories.

    Declaration

    Swift

    var treatsFilePackagesAsDirectories: Bool

    Objective-C

    @property BOOL treatsFilePackagesAsDirectories

    Return Value

    YEStrue if the panel displays file packages as directories; otherwise, NOfalse.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Sets the panel’s behavior for displaying file packages (for example, MyApp.app) to the user.

    Declaration

    Swift

    var treatsFilePackagesAsDirectories: Bool

    Objective-C

    @property BOOL treatsFilePackagesAsDirectories

    Parameters

    flag

    If YEStrue, the panel will display file packages as directories; if NOfalse, it will not.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Deprecation Statement

    Use beginSheetModalForWindow:completionHandler: instead.

    Declaration

    Objective-C

    - (void)beginSheetForDirectory:(NSString *)path file:(NSString *)name modalForWindow:(NSWindow *)docWindow modalDelegate:(id)modalDelegate didEndSelector:(SEL)didEndSelector contextInfo:(void *)contextInfo

    Parameters

    path

    Directory whose files the panel displays. When nil, the directory is the same directory used in the previous invocation of the panel; this is probably the best choice for most situations.

    name

    Specifies a particular file in path that is selected when the Save panel is presented to a user. When nil, no file is initially selected.

    docWindow

    If not nil, the Save panel slides down as a sheet running as a document modal window in docWindow. If nil, the behavior defaults to a standalone modal window.

    modalDelegate

    This is not the same as a delegate assigned to the panel. This delegate is temporary and the relationship only lasts until the panel is dismissed. The NSSavePanel object has a weak reference to the modal delegate.

    didEndSelector

    Message sent to modalDelegate after the modal session has ended, but before dismissing the Save panel. didEndSelector may dismiss the Save panel itself; otherwise, it is dismissed on return from the method. The corresponding method should have the following signature:

    • - (void)savePanelDidEnd:(NSSavePanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo;

    The value passed as returnCode is either NSCancelButton or NSOKButton.

    contextInfo

    Context information passed to modalDelegate in the didEndSelector message.

    Import Statement

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.6.

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

    Declaration

    Swift

    func beginSheetModalForWindow(_ window: NSWindow, completionHandler handler: (Int) -> Void)

    Objective-C

    - (void)beginSheetModalForWindow:(NSWindow *)window completionHandler:(void (^)(NSInteger result))handler

    Parameters

    window

    The window in which the panel will be presented.

    handler

    The block called after the user dismisses the panel. The argument passed in will be NSFileHandlingPanelOKButton if the user chose the OK button or NSFileHandlingPanelCancelButton if the user chose the Cancel button.

    Discussion

    Any properties of the panel you wish to set should be set before calling this method. Although the completion handler block is called after the user dismisses the panel, the panel sheet may still be visible onscreen. If you need to remove the sheet from the screen—for example, if the completion block displays an alert—first call [savePanel orderOut:nil] to close the sheet.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • Presents the panel as a modeless window.

    Declaration

    Swift

    func beginWithCompletionHandler(_ handler: (Int) -> Void)

    Objective-C

    - (void)beginWithCompletionHandler:(void (^)(NSInteger result))handler

    Parameters

    handler

    The block called after the user has closed the panel. The argument passed in will be NSFileHandlingPanelOKButton if the user chose the OK button or NSFileHandlingPanelCancelButton if the user chose the Cancel button.

    Discussion

    Any properties of the panel you wish to set should be set before calling this method.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.6 and later.

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

    Declaration

    Swift

    func runModal() -> Int

    Objective-C

    - (NSInteger)runModal

    Return Value

    NSFileHandlingPanelOKButton (if the user clicks the OK button) or NSFileHandlingPanelCancelButton (if the user clicks the Cancel button).

    Discussion

    This method invokes NSApplication‘s runModalForWindow: method with self as the argument.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    runModalForWindow: (NSApplication)

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

    Deprecation Statement

    Use runModal instead.

    Declaration

    Objective-C

    - (NSInteger)runModalForDirectory:(NSString *)path file:(NSString *)filename

    Parameters

    path

    Directory whose files the panel displays. When nil, the directory is the same directory used in the previous invocation of the panel; this is probably the best choice for most situations.

    filename

    Specifies a particular file in path that is selected when the Save panel is presented to a user. When nil, no file is initially selected.

    Return Value

    NSFileHandlingPanelOKButton (if the user clicks the OK button) or NSFileHandlingPanelCancelButton (if the user clicks the Cancel button).

    Discussion

    This method invokes NSApplication’s runModalForWindow: method with self as the argument.

    Import Statement

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.6.

    See Also

    – runModal
    runModalForWindow: (NSApplication)

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

    Deprecation Statement

    There is no replacement.

    Objective-C

    - (NSComparisonResult)panel:(id)sender compareFilename:(NSString *)fileName1 with:(NSString *)fileName2 caseSensitive:(BOOL)flag

    Discussion

    Don’t reorder filenames in the Save panel without good reason, because it may confuse the user to have files in one Save panel or Open panel ordered differently than those in other such panels or in the Finder. The default behavior of Save and Open panels is to order files as they appear in the Finder. Note also that by implementing this method you will reduce the operating performance of the panel.

    Import Statement

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.6.

  • Gives the delegate the opportunity to validate selected items.

    Deprecation Statement

    Use panel:validateURL:error: (NSOpenSavePanelDelegate) instead. If both methods are implemented, the URL version will be called.

    Objective-C

    - (BOOL)panel:(id)sender isValidFilename:(NSString *)filename

    Discussion

    The NSSavePanel object sender sends this message just before the end of a modal session for each filename displayed or selected (including filenames in multiple selections). If the delegate refuses a filename in a multiple selection, none of the filenames in the selection is accepted.

    Import Statement

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.6.

    See Also

    panel:validateURL:error: (NSOpenSavePanelDelegate)

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

    Declaration

    Swift

    func validateVisibleColumns()

    Objective-C

    - (void)validateVisibleColumns

    Discussion

    You might use this method if you want the browser to only allow selection of 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.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Deprecation Statement

    Use panel:shouldEnableURL: (NSOpenSavePanelDelegate).

    Objective-C

    - (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename

    Discussion

    The NSSavePanel object sender sends this message to the panel’s delegate for each file or directory (filename) it is about to load in the browser.

    Import Statement

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.6.

    See Also

    panel:shouldEnableURL: (NSOpenSavePanelDelegate).

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

    Deprecation Statement

    Use panel:didChangeToDirectoryURL: (NSOpenSavePanelDelegate) instead.

    Objective-C

    - (void)panel:(id)sender directoryDidChange:(NSString *)path

    Import Statement

    Availability

    Available in OS X v10.3 and later.

    Deprecated in OS X v10.6.

    See Also

    panel:didChangeToDirectoryURL: (NSOpenSavePanelDelegate)

  • directory directory (OS X v10.6)

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

    Deprecation Statement

    Use directoryURL instead.

    Declaration

    Objective-C

    - (NSString *)directory

    Return Value

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

    Import Statement

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.6.

  • filename filename (OS X v10.6)

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

    Deprecation Statement

    Use URL instead.

    Declaration

    Objective-C

    - (NSString *)filename

    Return Value

    The absolute pathname of the file.

    Import Statement

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.6.

    See Also

    – URL

  • Returns the directory shown in the panel as a URL.

    Declaration

    Swift

    @NSCopying var directoryURL: NSURL?

    Objective-C

    @property(copy) NSURL *directoryURL

    Return Value

    The directory’s URL.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.6 and later.

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

    Declaration

    Swift

    @NSCopying var URL: NSURL? { get }

    Objective-C

    @property(readonly, copy) NSURL *URL

    Return Value

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

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • isExpanded isExpanded Available in OS X v10.0 through OS X v10.9

    Returns a Boolean value that indicates whether the panel is expanded.

    Declaration

    Objective-C

    - (BOOL)isExpanded

    Return Value

    YEStrue if the panel is expanded; otherwise, NOfalse.

    Import Statement

    Availability

    Available in OS X v10.0 through OS X v10.9.

  • Returns the user-editable filename currently shown in the name field.

    Declaration

    Swift

    var nameFieldStringValue: String

    Objective-C

    @property(copy) NSString *nameFieldStringValue

    Return Value

    The filename currently selected.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • selectText: selectText: (OS X v10.3)

    This method has been deprecated.

    Deprecation Statement

    There is no replacement.

    Declaration

    Objective-C

    - (IBAction)selectText:(id)sender

    Import Statement

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.3.

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

    Declaration

    Swift

    @IBAction func ok(_ sender: AnyObject?)

    Objective-C

    - (IBAction)ok:(id)sender

    Parameters

    sender

    The NSSavePanel object whose OK button was clicked.

    Discussion

    Sandboxed apps cannot programmatically invoke the OK button.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    – cancel:

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

    Declaration

    Swift

    @IBAction func cancel(_ sender: AnyObject?)

    Objective-C

    - (IBAction)cancel:(id)sender

    Parameters

    sender

    The NSSavePanel object whose Cancel button was clicked.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    – ok:

  • Button tags that refer to items on the panel.

    Declaration

    Swift

    var NSFileHandlingPanelCancelButton: Int { get } var NSFileHandlingPanelOKButton: Int { get }

    Objective-C

    enum { NSFileHandlingPanelCancelButton = NSCancelButton, NSFileHandlingPanelOKButton = NSOKButton };

    Constants

    • NSFileHandlingPanelCancelButton

      NSFileHandlingPanelCancelButton

      The Cancel button.

      Available in OS X v10.0 and later.

    • NSFileHandlingPanelOKButton

      NSFileHandlingPanelOKButton

      The OK button.

      Available in OS X v10.0 and later.

    Import Statement