Is there a way to read the app's bundled plist file, I am want开发者_如何学编程ing to pull the value for Bundle version.
See Getting the Bundle’s Info.plist Data.
[[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
should get you the bundle version.
In Swift you can use:
let bundleVersion = Bundle.main.object(forInfoDictionaryKeykCFBundleVersionKey as String) as! String
or:
let bundleVersion = Bundle.main.infoDictionary?[kCFBundleVersionKey as String] as! String
If you want the short bundle versions string, you can use:
let shortBundleVersion = Bundle.main.object(forInfoDictionaryKey:"CFBundleShortVersionString") as! String
#define APP_VERSION [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString*)kCFBundleVersionKey]
精彩评论