2

我有一个案例,其中[[NSBundle mainBundle] infoDictionary]只包含这个:

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: }

但我想获得 CFBundleIdentifier。

是否有另一种(更一般的)方法来获取当前进程的 CFBundleIdentifier?

4

2 回答 2

4

[[NSRunningApplication runningApplicationWithProcessIdentifier:getpid()] bundleIdentifier]作品。

于 2011-09-17T17:17:43.613 回答
0
NSString *CFBundleIdentifier = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"];


(CFBundleIdentifier = @"com.yourcompany.yourapp")
于 2016-06-23T09:52:02.917 回答