Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys. I am a new Mac user. I'm trying to learn how to program in this great OS, with this language totally new for me. I already know the C language, but I've never used some object oriented language, then excuse me if I'll say something stupid...
I'm trying to create a simple file browser to select a file in a folder on my system. I would use a Browser object, but I don't know how to display its content. Reading Apple's documentation I understood that I have to fill my NSBrowser object with an NSBrowserCell object and so on... But I don't really know how to do this!
I hope you can help me...
Posted

1 solution

Take a look at the NSOpenPanel class, I think that is a good starting point:

Objective-C
// Create the File Open Dialog class.
NSOpenPanel* openDlg = [NSOpenPanel openPanel];

// Enable the selection of files in the dialog.
[openDlg setCanChooseFiles:YES];

// Multiple files not allowed
[openDlg setAllowsMultipleSelection:NO];

// Can't select a directory
[openDlg setCanChooseDirectories:NO];

// Display the dialog. If the OK button was pressed,
// process the files.
if ( [openDlg runModalForDirectory:nil file:nil] == NSOKButton )
{
   ....
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900