Defining An Application's Self Path?

Discussion in 'Mac Programming' started by Darkroom, Nov 29, 2008.

  1. Darkroom Guest

    Darkroom

    Joined:
    Dec 15, 2006
    Location:
    Montréal, Canada
    #1
    so in theApp.app's code it's possible to define the path of this app that is placed in a specific folder:

    Code:
    #define applicationPath @"/Applications/[I]theApp.app[/I]"
    
    but this reference doesn't work if the user places theApp.app on the desktop, or in the downloads folder, etc... is there a way to define the path of an app using a wildcard or something?
     
  2. Guiyon macrumors 6502a

    Joined:
    Mar 19, 2008
    Location:
    North Shore, MA
    #2
    Since you're working in Cocoa, your best bet would be to use:
    Code:
    NSString *applicationPath = [[NSBundle mainBundle] bundlePath]
    IIRC, that should return the path to the main bundle of the currently executing application.
     
  3. Darkroom thread starter Guest

    Darkroom

    Joined:
    Dec 15, 2006
    Location:
    Montréal, Canada

Share This Page