Re: Where am I if I'm a .App package?
Re: Where am I if I'm a .App package?
- Subject: Re: Where am I if I'm a .App package?
- From: Scott Harper <email@hidden>
- Date: Tue, 4 Oct 2005 01:09:04 -0600
On 03 Oct, 2005, at 10:53 PM, Sherm Pendley wrote:
On Oct 4, 2005, at 12:34 AM, Scott Harper wrote:
I would like to know how I can (hopefully there's an easy way)
discover the path to the currently running .app's directory
NSString *appDir = [[NSBundle mainBundle] bundlePath];
, so say I'm a running program, and I want to access a settings
file located in the same directory where _I_ am located
What exactly to you mean by "access"? That directory may not be
writable by the user running the app. Anyway, you should be using
NSUserDefaults to manage settings. That's what it's for.
If you want to read the default settings from a plist or other read-
only file, you should store that in the .app bundle as a resource -
but you don't need to know the .app path to get at resources, you
can simply use one of NSBundle's -getPathForResource* methods to
get that.
-- or I have customizable media I want to load that's stored in a
"media" directory alongside myself
Nothing should be in /Applications except application .app bundles.
External files - templates, media, etc. is what the "/Library/
Application Support" directory is for.
sherm--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
Thanks for the tips! I AM using User Defaults for the app's
preferences. What it is is a customizable template file (XML, not
PList, though I gather they'll do the same things) storing a
structure, name, and paths for images to be used and organised in an
NSOutlineView... As I want the media contained within the file to be
modifiable by the user, where should I store everything?
What I was thinking was have the initial XML file in the app's
bundle, then include the default template images in a media folder
within the app's directory, say /Applications/MyApp/media or some
such naming scheme. What should I be doing instead, and what
frameworks/etc should I be looking into to do this "correctly"
according to Apple's standards?
Thanks so much for the help! ^_^
--Scott
_______________________________________________
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