Cocoa/ObjC: get CFBundleIdentifier of current process
-
21-01-2021 - |
Вопрос
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?
Решение
[[NSRunningApplication runningApplicationWithProcessIdentifier:getpid()] bundleIdentifier]
works.
Другие советы
NSString *CFBundleIdentifier = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"];
(CFBundleIdentifier = @"com.yourcompany.yourapp")
Не связан с StackOverflow