我有一个[[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?
答案 0 :(得分:4)
[[NSRunningApplication runningApplicationWithProcessIdentifier:getpid()] bundleIdentifier]
有效。
答案 1 :(得分:0)
NSString *CFBundleIdentifier = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"];
(CFBundleIdentifier = @"com.yourcompany.yourapp")