• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Retrieving application name during runtime
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Retrieving application name during runtime


  • Subject: Re: Retrieving application name during runtime
  • From: Douglas Davidson <email@hidden>
  • Date: Fri, 10 Dec 2004 18:37:38 -0800


On Dec 10, 2004, at 2:47 PM, Louis Sinclair wrote:


You can get the path to the running executable with the following:

NSBundle* bundle = [NSBundle mainBundle];
NSString* path = [[NSString alloc] initWithString:[bundle executablePath]];
<do something with the string>
[path release];

You can just use [[NSBundle mainBundle] bundlePath] for the full path to the application bundle, [[NSBundle mainBundle] executablePath] for the full path to the executable. For an unbundled executable, these will return the path to the directory in which the executable sits and the path to the executable.


An application may have several names--the CFBundleName, CFBundleDisplayName, etc. See the bundle documentation for more information. These can be obtained programmatically using [[NSBundle mainBundle] objectForInfoDictionaryKey:].

Command-line arguments can be obtained from [[NSProcessInfo processInfo] arguments]. NSProcessInfo also can give you some other related information such as environment variables.

Douglas Davidson

_______________________________________________
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


References: 
 >Retrieving application name during runtime (From: Peter <email@hidden>)
 >Re: Retrieving application name during runtime (From: Louis Sinclair <email@hidden>)

  • Prev by Date: Displaying an NSArray of NSArray's in a Table view
  • Next by Date: Re: Retrieving application name during runtime
  • Previous by thread: Re: Retrieving application name during runtime
  • Next by thread: Re: Retrieving application name during runtime
  • Index(es):
    • Date
    • Thread