获取版本号[[NSBundle mainBundle] infoDictionary]

很多朋友改版本号,通过改变属性,比如说self.versionLabel = @”1.0”,版本更新后,self.versionLabel = @”1.1” 
如果通过这样改,那就很麻烦了。但是如果通过代码获取info的version信息,那就很方便,以后版本更换后,只需要改变info的version,就可以了。

//获取当前版本号

    NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];
    NSLog(@"%@",infoDic);
    NSString *currentAppVersion = infoDic[@"CFBundleShortVersionString"];
 
 
  • 1
  • 2
  • 3
  • 1
  • 2
  • 3

infoDic包含如下所有的信息:也就是我们的程序信息:

{

BuildMachineOSBuild = 15C50; 
CFBundleDevelopmentRegion = en; 
CFBundleExecutable = ZYGLaunchIntroductionDemo; 
CFBundleIdentifier = “com.huaxinlongma.ZYGLaunchIntroductionDemo”; 
CFBundleInfoDictionaryVersion = “6.0”; 
CFBundleInfoPlistURL = “Info.plist – file:///Users/lanouhn/Library/Developer/CoreSimulator/Devices/84454B75-C87C-4752-A24B-095EAAC00443/data/Containers/Bundle/Application/09AB9754-B19E-4F63-869B-B8D6C319EE85/ZYGLaunchIntroductionDemo.app/”; 
CFBundleName = ZYGLaunchIntroductionDemo; 
CFBundleNumericVersion = 16809984; 
CFBundlePackageType = APPL; 
CFBundleShortVersionString = “1.0”; 
CFBundleSignature = “????”; 
CFBundleSupportedPlatforms = ( 
iPhoneSimulator 
); 
CFBundleVersion = 1; 
DTCompiler = “com.apple.compilers.llvm.clang.1_0”; 
DTPlatformBuild = “”; 
DTPlatformName = iphonesimulator; 
DTPlatformVersion = “9.2”; 
DTSDKBuild = 13C75; 
DTSDKName = “iphonesimulator9.2”; 
DTXcode = 0720; 
DTXcodeBuild = 7C68; 
LSRequiresIPhoneOS = 1; 
MinimumOSVersion = “8.1”; 
UIDeviceFamily = ( 

); 
UILaunchStoryboardName = LaunchScreen; 
UIRequiredDeviceCapabilities = ( 
armv7 
); 
UISupportedInterfaceOrientations = ( 
UIInterfaceOrientationPortrait, 
UIInterfaceOrientationLandscapeLeft, 
UIInterfaceOrientationLandscapeRight 
); 
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值