Skip to content

Instantly share code, notes, and snippets.

@cmendesce
Created June 14, 2014 14:07
Show Gist options
  • Select an option

  • Save cmendesce/4f9aecb87d75c3f38003 to your computer and use it in GitHub Desktop.

Select an option

Save cmendesce/4f9aecb87d75c3f38003 to your computer and use it in GitHub Desktop.
// Insert code here to initialize your application
NSOpenPanel* openDlg = [NSOpenPanel openPanel];
// Enable the selection of files in the dialog.
[openDlg setCanChooseFiles:NO];
// Multiple files not allowed
[openDlg setAllowsMultipleSelection:NO];
// Can't select a directory
[openDlg setCanChooseDirectories:YES];
// Display the dialog. If the OK button was pressed,
// process the files.
if ( [openDlg runModal] == NSOKButton )
{
// Get an array containing the full filenames of all
// files and directories selected.
NSArray* urls = [openDlg URLs];
// Loop through all the files and process them.
for(int i = 0; i < [urls count]; i++ )
{
NSString* url = [urls objectAtIndex:i];
NSLog(@"Url: %@", url);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment