我的iphone应用程序如何检测自己的版本号? [英] How can my iphone app detect its own version number?
问题描述
我正在写一个iPhone应用程序。它已经发布了,但我想添加一个显示其版本号的功能。
I'm writing an iPhone app. It's already been published, but I would like to add a feature where its version number is displayed.
我不想手动对我发布的每个版本执行此操作...
I'd rather not have to do this manually with each version I release...
在Objective-C中是否有办法找出我的应用程序的版本?
Is there a way in objective-C to find out what the version is of my app?
推荐答案
正如我在此描述的那样,我使用脚本用我当前的Subversion版本号重写头文件。该修订号存储在kRevisionNumber常量中。然后,我可以使用类似于以下内容的方式访问版本和修订号:
As I describe here, I use a script to rewrite a header file with my current Subversion revision number. That revision number is stored in the kRevisionNumber constant. I can then access the version and revision number using something similar to the following:
[NSString stringWithFormat:@"Version %@ (%@)", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"], kRevisionNumber]
将创建格式为Version 1.0(51)的字符串。
which will create a string of the format "Version 1.0 (51)".
这篇关于我的iphone应用程序如何检测自己的版本号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!