2011-09-17 3 views
1

J'ai un cas où [[NSBundle mainBundle] infoDictionary] ne contient que ceci:Cocoa/ObjC: obtenir CFBundleIdentifier du processus actuel

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

Mais je veux obtenir le CFBundleIdentifier.

Existe-t-il un autre moyen (plus général) d'obtenir l'identificateur CFBundleIdentifier du processus en cours?

Répondre

3

[[NSRunningApplication runningApplicationWithProcessIdentifier:getpid()] bundleIdentifier] fonctionne.

+0

Vous êtes toujours bien mieux que moi :) – Yuji

+0

Est-ce que '[[NSBundle mainBundle] bundleIdentifier]' fonctionne? Ce serait la solution la plus simple ... – MrMage

+0

@MrMage: Non, cela retourne 'nil'. – Albert

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


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