Answers:
物镜
NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
斯威夫特1.2
let bundleIdentifier = NSBundle.mainBundle().bundleIdentifier
斯威夫特3.0
let bundleIdentifier = Bundle.main.bundleIdentifier
Xamarin.iOS
var bundleIdentifier = NSBundle.MainBundle.BundleIdentifier
let bundleIdentifier = NSBundle.mainBundle().bundleIdentifier
Bundle.main.bundleIdentifier!
[[NSBundle mainBundle] bundleIdentifier];
(文件)
let bundleIdentifier = NSBundle.mainBundle().bundleIdentifier
您可能需要Core Foundation方法来获取价值。ARC示例如下:
NSString *value = (__bridge_transfer NSString *)CFDictionaryGetValue(CFBundleGetInfoDictionary(CFBundleGetMainBundle()),
(const void *)(@"CFBundleIdentifier"));