Name

NSOpenPanel — Mac OS X 10.0

Synopsis

This subclass of NSSavePanel implements a Mac OS X Open panel with which users are presented a filesystem browser interface to choose files or directories for the application to open. The Open panel is created by invoking the class method openPanel, and is displayed onscreen using any of the runModal... or beginSheet... methods. After an Open panel has been closed by the user, an application can obtain an array of the selected files or directories as paths or URLs using the method filenames or URLs.

image with no caption

@interface NSOpenPanel : NSSavePanel
                                  // Accessor Methods
   - (void)setCanChooseDirectories:(BOOL)flag;
   - (BOOL)canChooseDirectories;
   - (void)setCanChooseFiles:(BOOL)flag;
   - (BOOL)canChooseFiles;
   - (void)setResolvesAliases:(BOOL)flag;
   - (BOOL)resolvesAliases;
   - (void)setAllowsMultipleSelection:(BOOL)flag;
   - (BOOL)allowsMultipleSelection;
                                  // Class Methods
   + (NSOpenPanel *)openPanel;
                                  // Instance Methods
   - (NSArray *)URLs;
   - (void)beginSheetForDirectory:(NSString *)path 
                                 file:(NSString *)name 
                                 types:(NSArray *)fileTypes
                                 modalForWindow:(NSWindow *)docWindow  
                                 modalDelegate:(id)delegate  
                                 didEndSelector:(SEL)didEndSelector
                                 contextInfo:(void *)contextInfo;
   - (NSArray *)filenames;
   - (int)runModalForDirectory:(NSString *)path 
                                 file:(NSString *)name 
                                 types:(NSArray *)fileTypes;
   - (int)runModalForDirectory:(NSString *)path 
                                 file ...

Get Cocoa in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.