How to get the path of bundle application

Discussion in 'Mac Programming' started by Tank2005, Jan 18, 2011.

  1. Tank2005 macrumors newbie

    Joined:
    Apr 24, 2009
    #1
    I developing Photoshop Plug-in(xcode bundle project).
    I want to get the path of own bundle program.
    My ideal is that returns such as "MyPlugin.plugin". But, follow code returns "Photoshop.app".
    NSString *mpath = [[NSBundle mainBundle]bundlePath];

    Please teach me.
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    The main bundle is always the bundle of the actual executing app. As plugins execute within the app process this will not get you what you want.

    NSBundle provides the bundleForClass: method. If you pass this the class object for a class in your bundle then you will get what you want.

    If we assume the main class in your plugin is called MyPluginClass then this would work:

    Code:
    NSString *mpath = [[NSBundle bundleForClass:[MyPluginClass  class]] bundlePath];
    
    (note code tags make everyones life better: use them)
     
  3. Tank2005 thread starter macrumors newbie

    Joined:
    Apr 24, 2009

Share This Page