iOS应用,以编程方式获取构建版本 [英] iOS app, programmatically get build version
本文介绍了iOS应用,以编程方式获取构建版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法以编程方式获取我的应用的构建版本?我需要能够检测用户何时通过AppStore更新了应用,以便执行一些调整代码
Is there a way to programmatically get the build version of my app? I need to be able to detect when the user has updated the app through the AppStore, in order to execute some code for adjustments
推荐答案
您在Xcode目标摘要的版本"字段中设置的值位于此处:
The value you set in the Xcode target summary's "Version" field is in here:
雨燕3
let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as! String
ObjC
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
雨燕2
let version = NSBundle.mainBundle().infoDictionary?["CFBundleShortVersionString"] as! String
和内部版本":
雨燕3
let build = Bundle.main.infoDictionary?[kCFBundleVersionKey as String] as? String
ObjC
NSString *build = [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey];
雨燕2
let build = NSBundle.mainBundle().infoDictionary?[kCFBundleVersionKey as String] as! String
这篇关于iOS应用,以编程方式获取构建版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文