NSOpenPanel Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/AppKit.framework |
| Availability | Available in OS X v10.0 and later. |
| Declared in | NSOpenPanel.h |
| Companion guides | |
Overview
The NSOpenPanel class provides the Open panel for the Cocoa user interface. Applications use the Open panel as a convenient way to query the user for the name of a file to open.
In a sandboxed environment, Open panels are drawn in a separate process by the powerbox, not by AppKit itself. When the user chooses a file to open, OS X adds that file to the app’s sandbox.
Tasks
Creating Panels
Configuring Panels
-
– canChooseFiles -
– setCanChooseFiles: -
– canChooseDirectories -
– setCanChooseDirectories: -
– resolvesAliases -
– setResolvesAliases: -
– allowsMultipleSelection -
– setAllowsMultipleSelection:
Running Panels
-
– beginForDirectory:file:types:modelessDelegate:didEndSelector:contextInfo:Deprecated in OS X v10.6 -
– beginSheetForDirectory:file:types:modalForWindow:modalDelegate:didEndSelector:contextInfo:Deprecated in OS X v10.6 -
– runModalForDirectory:file:types:Deprecated in OS X v10.6 -
– runModalForTypes:Deprecated in OS X v10.6
Accessing User Selection
-
– URLs -
– filenamesDeprecated in OS X v10.6
Class Methods
openPanel
Creates and returns a NSOpenPanel object.
Return Value
The initialized Open panel.
Availability
- Available in OS X v10.0 and later.
Declared In
NSOpenPanel.hInstance Methods
allowsMultipleSelection
Returns whether the panel’s browser allows the user to open multiple files (and directories) at a time.
Return Value
YES if the panel’s browser allows multiple selection; otherwise, NO.
Discussion
If multiple files or directories are allowed, then the filename method—inherited from NSSavePanel—returns a non-nil value only if one and only one file is selected. By contrast, NSOpenPanel’s URLs method always returns the URLs of the selected files, even if only one file is selected.
Availability
- Available in OS X v10.0 and later.
See Also
-
– URL(NSSavePanel) -
– URLs -
– setAllowsMultipleSelection:
Declared In
NSOpenPanel.hcanChooseDirectories
Returns whether the panel allows the user to choose directories to open.
Return Value
YES if the panel allows the user to choose directories; otherwise, NO.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSOpenPanel.hcanChooseFiles
Returns whether the panel allows the user to choose files to open.
Return Value
YES if the panel allows the user to choose files; otherwise, NO.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSOpenPanel.hresolvesAliases
Returns whether the panel resolves aliases.
Return Value
YES if the panel resolves aliases; otherwise, NO.
Discussion
If YES, the effect is that dropping an alias on the panel or asking for filenames or URLs returns the resolved aliases. The default is YES.
Availability
- Available in OS X v10.1 and later.
See Also
Declared In
NSOpenPanel.hsetAllowsMultipleSelection:
Sets whether the user can select multiple files (and directories) at one time for opening.
Parameters
- flag
If
YES, the panel’s browser allows multiple selection; ifNO, it does not.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSOpenPanel.hsetCanChooseDirectories:
Sets whether the user can select directories in the panel’s browser.
Parameters
- flag
If
YES, the panel allows the user to choose directories; ifNO, it does not.
Discussion
When a directory is selected, the OK button is enabled only if flag is YES.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSOpenPanel.hsetCanChooseFiles:
Sets whether the user can select files in the panel’s browser.
Parameters
- flag
If
YES, the panel allows the user to choose files; ifNO, it does not.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSOpenPanel.hsetResolvesAliases:
Sets whether the panel resolves aliases.
Parameters
- resolvesAliases
If
YES, the panel resolves aliases; ifNO, it does not.
Discussion
If YES, the effect is that dropping an alias on the panel or asking for filenames or URLs returns the resolved aliases. Set this value to NO to allow selection of aliases without resolving.
Availability
- Available in OS X v10.1 and later.
See Also
Declared In
NSOpenPanel.hURLs
Returns an array containing the absolute paths of the selected files and directories as URLs.
Return Value
The array of URLs.
Discussion
If multiple selections aren’t allowed, the array contains a single name.
Availability
- Available in OS X v10.0 and later.
Declared In
NSOpenPanel.h© 2012 Apple Inc. All Rights Reserved. (Last updated: 2012-01-09)