GtkFileChooserDialog in Cocoa
I justa want to know if there's a class like GtkFileChooserDialog in Cocoa. This class is used in gtk for 开发者_运维百科opening a file.
Yes there is, NSOpenPanel.
NSOpenPanel *panel = [NSOpenPanel openPanel];
int result = [panel runModal];
if (result == NSOKButton) {
NSArray *allSelectedFiles = [panel URLs];
NSURL *selectedFileURL = [allSelectedFiles objectAtIndex:0];
NSLog(@"Selected: %@", selectedFileURL);
}
NSOpenPanel Class Reference
精彩评论