如何向用户显示我的应用程序的当前项目版本? [英] How to display the current project version of my App to the user?

查看:162
本文介绍了如何向用户显示我的应用程序的当前项目版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将目前版本加入我应用程式的「关于」部分。

I would like to add the current version into the "about" section of my app. As seen in this attached screenshot Apple offers versioning.

如何在应用程式中显示这些设定?

How do you display these settings in your app?

推荐答案

进一步搜索和测试后,我自己找到了解决方案。

After further searching and testing, I found the solution myself.

NSDictionary* infoDictionary = [[NSBundle mainBundle] infoDictionary];
NSLog(@"%i Keys:  %@", [infoDictionary count],
             [[infoDictionary allKeys] componentsJoinedByString: @" ,"]);

这个snipplet给了我以下输出:

This snipplet gave me the following output:

20个按键:NSBundleResolvedPath, CFBundleVersion ,NSBundleInitialPath,CFBundleIdentifier,NSMainNibFile,CFBundleIconFile,CFBundleInfoPlistURL,CFBundleExecutable,DTSDKName,UIStatusBarStyle,CFBundleDevelopmentRegion,DTPlatformName,CFBundleInfoDictionaryVersion,CFBundleSupportedPlatforms,CFBundleExecutablePath,CFBundleDisplayName ,LSRequiresIPhoneOS,CFBundlePackageType,CFBundleSignature,CFBundleName

20 Keys : NSBundleResolvedPath ,CFBundleVersion ,NSBundleInitialPath ,CFBundleIdentifier ,NSMainNibFile ,CFBundleIconFile ,CFBundleInfoPlistURL ,CFBundleExecutable ,DTSDKName ,UIStatusBarStyle ,CFBundleDevelopmentRegion ,DTPlatformName ,CFBundleInfoDictionaryVersion ,CFBundleSupportedPlatforms ,CFBundleExecutablePath ,CFBundleDisplayName ,LSRequiresIPhoneOS ,CFBundlePackageType ,CFBundleSignature ,CFBundleName

所以解决方案很简单:

NSString *version =[[[NSBundle mainBundle] infoDictionary] valueForKey:@"CFBundleVersion"];

但是,这是当前项目版本但是plist文件的Bundle版本。

However, this is not the Current Project Version as seen in the screenshot but the Bundle Version of the plist file.

这篇关于如何向用户显示我的应用程序的当前项目版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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