objective-cmacoscocoacfbundleidentifier

Cocoa/ObjC: get CFBundleIdentifier of current process


I have a case where [[NSBundle mainBundle] infoDictionary] does only contain this:

17.09.11 18:28:26,936 [0x0-0x5a98a93].com.valvesoftware.steam: 2011-09-17 18:28:26.935 steam[85587:707] infodict: {
17.09.11 18:28:26,936 [0x0-0x5a98a93].com.valvesoftware.steam:     CFBundleExecutablePath = "/Applications/Spiele/Steam.app/Contents/MacOS/osx32/steam";
17.09.11 18:28:26,936 [0x0-0x5a98a93].com.valvesoftware.steam:     NSBundleInitialPath = "/Applications/Spiele/Steam.app/Contents/MacOS/osx32";
17.09.11 18:28:26,936 [0x0-0x5a98a93].com.valvesoftware.steam:     NSBundleResolvedPath = "/Applications/Spiele/Steam.app/Contents/MacOS/osx32";
17.09.11 18:28:26,936 [0x0-0x5a98a93].com.valvesoftware.steam: }

But I want to get the CFBundleIdentifier.

Is there another (more general) way to get the CFBundleIdentifier of the current process?


Solution

  • [[NSRunningApplication runningApplicationWithProcessIdentifier:getpid()] bundleIdentifier] works.