简体   繁体   English

可可/ ObjC:获取当前进程的CFBundleIdentifier

[英]Cocoa/ObjC: get CFBundleIdentifier of current process

I have a case where [[NSBundle mainBundle] infoDictionary] does only contain this: 我有一种情况, [[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: }

But I want to get the CFBundleIdentifier. 但是我想获取CFBundleIdentifier。

Is there another (more general) way to get the CFBundleIdentifier of the current process? 是否有另一种(更通用的)方式来获取当前进程的CFBundleIdentifier?

[[NSRunningApplication runningApplicationWithProcessIdentifier:getpid()] bundleIdentifier]有效。

NSString *CFBundleIdentifier = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"];


(CFBundleIdentifier = @"com.yourcompany.yourapp")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM