请参考代码中的内部版本号或版本号 [英] Refer to build number or version number in code

查看:130
本文介绍了请参考代码中的内部版本号或版本号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Xcode中手动设置内部版本号和版本号很容易,我学习了如何在构建时使用宏来增加它们.但是,如何在代码中引用它们的值?

It's easy to set the build and version numbers manually in Xcode, and I learned how to increment them with a macro at build time. But how do I reference their values in code?

推荐答案

当然,您可以向主捆绑包索取info目录,其中包括info.plist的所有键和值,包括版本号:

Sure, you can ask your main bundle for the info directory which includes all keys and values of your info.plist, including the version number:

NSDictionary *info = [[NSBundle mainBundle] infoDictionary];
NSString *version = [info objectForKey:@"CFBundleShortVersionString"];

这篇关于请参考代码中的内部版本号或版本号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆