Re: currentDirectoryPath returns different paths
Re: currentDirectoryPath returns different paths
- Subject: Re: currentDirectoryPath returns different paths
- From: Sherm Pendley <email@hidden>
- Date: Thu, 27 Jul 2006 09:34:18 -0400
On Jul 27, 2006, at 6:50 AM, <email@hidden>
<email@hidden> wrote:
I use the method currentDirectoryPath to get the current location
of my app.
That method doesn't return the location of your app. It returns (as
its name implies) the current working directory, which is not the
same thing.
When I run the application from X Code itself i.e a build and go the
currentDirectoryPath returns the correct path say for e.g
/Users/amrit//MyApplication/build/Debug
For the same application when i go to the directory
/Users/amrit//MyApplication/build/Debug and click on the application
icon
the method currentDirectoryPath returns " / " .The same is the
case if
I try to launch the application from any other directory.
Why is it so?
The current working directory varies according to how your app is
launched. In addition to the above, you could open a Terminal window,
use 'cd' to change the current directory, and 'open' to open your app.
How do I get the actual current working directory?
You *are* getting the correct current working directory - that's just
not what you expected it to be. :-)
If what you want is the path to your app, you can use NSBundle methods:
NSString *appPath = [[NSBundle mainBundle] executablePath];
Note that NSBundle also has a lot of methods for obtaining paths to
various (possibly localized) other things inside your .app bundle.
NSImage also has convenience methods for loading image resources.
sherm--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden