Deprecated NSOpenPanel Methods

A method identified as deprecated has been superseded and may become unsupported in the future.

Deprecated in OS X v10.6

beginForDirectory:file:types:modelessDelegate:didEndSelector:contextInfo:

Presents a modeless Open panel. (Deprecated in OS X v10.6. Use beginWithCompletionHandler: instead. You can set absoluteDirectoryPath using setDirectoryURL:, and you can set fileTypes using setAllowedFileTypes:.)

- (void)beginForDirectory:(NSString *)absoluteDirectoryPath file:(NSString *)filename types:(NSArray *)fileTypes modelessDelegate:(id)modelessDelegate didEndSelector:(SEL)didEndSelector contextInfo:(void *)contextInfo
Parameters
absoluteDirectoryPath

The 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 absoluteDirectoryPath that is selected when the Open panel is presented to the user. When nil, no file is initially selected.

fileTypes

An array of file extensions and/or HFS file types. Specifies the files the panel allows the user to select. nil makes all files in absoluteDirectoryPath selectable by the user. An array of types passed in here will override one set using setAllowedFileTypes:.

modelessDelegate

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.

didEndSelector

The message sent to modelessDelegate after the panel’s session has ended, but before dismissing the Open panel. didEndSelector may dismiss the Open panel itself; otherwise, it will be dismissed on return from the method. The corresponding method should have the following signature:

- (void)openPanelDidEnd:(NSOpenPanel *)panel returnCode:(int)returnCode  contextInfo:(void  *)contextInfo

The value passed as returnCode will be either NSCancelButton or NSOKButton.

contextInfo

Any context information passed to modelessDelegate in the didEndSelector message.

Discussion

Similar to beginSheetForDirectory:file:types:modalForWindow:modalDelegate:didEndSelector:contextInfo:, but allows for modeless operation of the panel.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.6.
Declared In
NSOpenPanel.h

beginSheetForDirectory:file:types:modalForWindow:modalDelegate:didEndSelector:contextInfo:

Presents an Open panel as a sheet with the directory specified by absoluteDirectoryPath and optionally the file specified by filename selected. (Deprecated in OS X v10.6. Use beginSheetModalForWindow:completionHandler: instead. You can set absoluteDirectoryPath using setDirectoryURL:, and you can set fileTypes using setAllowedFileTypes:.)

- (void)beginSheetForDirectory:(NSString *)absoluteDirectoryPath file:(NSString *)filename types:(NSArray *)fileTypes modalForWindow:(NSWindow *)docWindow modalDelegate:(id)modalDelegate didEndSelector:(SEL)didEndSelector contextInfo:(void *)contextInfo
Parameters
absoluteDirectoryPath

The 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 absoluteDirectoryPath that is selected when the Open panel is presented to the user. When nil, no file is initially selected.

fileTypes

An array of file extensions and/or HFS file types. Specifies the files the panel allows the user to select. nil makes all files in absoluteDirectoryPath selectable by the user. An array of types passed in here will override one set using setAllowedFileTypes:.

docWindow

The window to open the sheet on.

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

didEndSelector

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

- (void)openPanelDidEnd:(NSOpenPanel *)panel returnCode:(int)returnCode  contextInfo:(void  *)contextInfo

The value passed as returnCode will be either NSCancelButton or NSOKButton.

contextInfo

Any context information passed to modalDelegate in the didEndSelector message.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.6.
Declared In
NSOpenPanel.h

filenames

Returns an array containing the absolute paths (as NSString objects) of the selected files and directories. (Deprecated in OS X v10.6. Use URLs instead.)

- (NSArray *)filenames
Return Value

The array of filenames.

Discussion

If multiple selections aren’t allowed, the array contains a single name. The filenames method is preferable over NSSavePanel’s filename to get the name or names of files and directories that the user has selected.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.6.
See Also
Declared In
NSOpenPanel.h

runModalForDirectory:file:types:

Displays the panel and begins a modal event loop that is terminated when the user clicks either OK or Cancel. (Deprecated in OS X v10.6. Use runModal instead. You can set path using setDirectoryURL:, and you can set fileTypes using setAllowedFileTypes:.)

- (NSInteger)runModalForDirectory:(NSString *)absoluteDirectoryPath file:(NSString *)filename types:(NSArray *)fileTypes
Parameters
absoluteDirectoryPath

The 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 absoluteDirectoryPath that is selected when the Open panel is presented to the user. When nil, no file is initially selected.

fileTypes

An array of file extensions and/or HFS file types. Specifies the files the panel allows the user to select. nil makes all files in absoluteDirectoryPath selectable by the user. An array of types passed in here will override one set using setAllowedFileTypes:.

Return Value

The button clicked to dismiss the dialog: NSOKButton for the OK button and NSCancelButton for the Cancel button.

Discussion

You can control whether directories and files appear in the browser with the setCanChooseDirectories: and setCanChooseFiles: methods.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.6.
See Also
Declared In
NSOpenPanel.h

runModalForTypes:

Displays the panel and begins a modal event loop that is terminated when the user clicks either OK or Cancel. (Deprecated in OS X v10.6. Use runModal instead. You can set fileTypes using setAllowedFileTypes:.)

- (NSInteger)runModalForTypes:(NSArray *)fileTypes
Parameters
fileTypes

An array of file extensions and/or HFS file types. Specifies the files the panel allows the user to select. nil makes all files selectable by the user. An array of types passed in here will override one set using setAllowedFileTypes:.

Return Value

The button used to dismiss the dialog: NSOKButton for the OK button and NSCancelButton for the Cancel button.

Discussion

This convenience method sends runModalForDirectory:nil file:nil types:fileTypes to the panel. See runModalForDirectory:file:types: for additional details.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.6.
See Also
Declared In
NSOpenPanel.h