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

来源:互联网 发布:netstat查看端口占用 编辑:程序博客网 时间:2024/04/19 14:42

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

//获取当前版本号

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

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 = (
1
);
UILaunchStoryboardName = LaunchScreen;
UIRequiredDeviceCapabilities = (
armv7
);
UISupportedInterfaceOrientations = (
UIInterfaceOrientationPortrait,
UIInterfaceOrientationLandscapeLeft,
UIInterfaceOrientationLandscapeRight
);
}

0 0
原创粉丝点击