Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > "choose file" in Obj-C

"choose file" in Obj-C
Thread Tools
Senior User
Join Date: Jun 2002
Location: UK
Status: Offline
Reply With Quote
Sep 1, 2002, 05:09 AM
 
In AppleScript it's very easy to get the path of a file you want to open:

POSIX path for (choose file)

How can I do the same in Obj-C????

I want to have a "Open file" dialog and then use the path in the code.

Thanx
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Sep 1, 2002, 05:48 AM
 
See the documentation for NSOpenPanel. It provides several methods for setting up and running an open panel.

For just a simple, totally un-special open panel, you'd use something about like this:
Code:
int button; NSString *path; NSOpenPanel *openPanel = [NSOpenPanel openPanel]; button = [openPanel runModelForDirectory:NSHomeDirectory() file:nil types:nil]; if (button == NSOKButton) { path = [[openPanel filenames] objectAtIndex:0]; // Do stuff with the file... }
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
VEGAN  (op)
Senior User
Join Date: Jun 2002
Location: UK
Status: Offline
Reply With Quote
Sep 1, 2002, 08:30 AM
 
Originally posted by Chuckit:
See the documentation for NSOpenPanel. It provides several methods for setting up and running an open panel.

For just a simple, totally un-special open panel, you'd use something about like this:
Code:
int button; NSString *path; NSOpenPanel *openPanel = [NSOpenPanel openPanel]; button = [openPanel runModelForDirectory:NSHomeDirectory() file:nil types:nil]; if (button == NSOKButton) { path = [[openPanel filenames] objectAtIndex:0]; // Do stuff with the file... }

THANKS
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 01:43 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2