| Conforms to | |
| Framework | /System/Library/Frameworks/AppKit.framework |
| Availability | Available in Mac OS X v10.6 and later. |
| Declared in | NSSavePanel.h |
| Companion guides |
The NSOpenSavePanelDelegate protocol defines the methods that a delegate of NSOpenPanel or NSSavePanel should implement.
Informs the delegate that the user changed the selected directory to the directory located at the specified URL. The URL may be nil if the current URL can’t be represented by an NSURL object.
- (void)panel:(id)sender didChangeToDirectoryURL:(NSURL *)url
The panel whose directory changed.
The URL of the new directory, or nil if it can’t be represented by an NSURL object.
NSSavePanel.hFor NSOpenPanel delegates, asks the delegate whether the specified URL should be enabled in the panel. This method is not called for NSSavePanel delegates; all URLs are always disabled.
- (BOOL)panel:(id)sender shouldEnableURL:(NSURL *)url
The panel asking whether the URL should be enabled.
The URL to be checked.
YES to allow the URL to be enabled in the panel; otherwise, NO.
Implementations of this method should be fast to avoid stalling the user interface. Use panel:validateURL:error: instead if processing will take a long time.
NSSavePanel.hTells the delegate that the user confirmed a filename choice by clicking Save in a Save panel.
- (NSString *)panel:(id)sender userEnteredFilename:(NSString *)filename confirmed:(BOOL)okFlag
The panel reporting the user’s confirmation of a filename choice.
The user’s filename choice.
If YES, the user clicked the Save button; if NO, the user did not.
You can either leave the filename alone, return a new filename, or return nil to cancel the save (and leave the Save panel as is). This method is called before any required extension is appended to the filename and before the Save panel asks the user to replace an existing file, if applicable.
Note that in the future, this method may be called multiple times in the sessions as the user types. In those cases, okFlag will be NO until the user confirms the choice, in which case okFlag will become YES. If the delegate does extensive validation or puts up alerts, it should do so only when okFlag is YES.
NSSavePanel.hFor NSSavePanel delegates, asks the delegate for file URL validation when the user chooses the Save button. For NSOpenPanel delegates, asks the delegate for file URL validation once for each selected filename (or directory) when the user chooses the Open button.
- (BOOL)panel:(id)sender validateURL:(NSURL *)url error:(NSError **)outError
The panel requesting URL validation.
The URL to be validated.
If an error occurred during validation, the error that occurred.
YES if the URL is an acceptable URL to save to or to open; otherwise, NO.
NSSavePanel.hTells the delegate that the Save panel is about to expand or collapse because the user clicked the disclosure triangle that displays or hides the file browser.
- (void)panel:(id)sender willExpand:(BOOL)expanding
The panel that is about to expand or collapse.
YES specifies that the panel is expanding; NO specifies that it is collapsing.
NSSavePanel.hTells the delegate that the user changed the selection in the specified Save panel.
- (void)panelSelectionDidChange:(id)sender
The panel whose selection changed.
NSSavePanel.hLast updated: 2009-04-05