IOS开发——在程序中获取Info.plist中的字段
2015-01-19 12:39
1111 查看
IOS开发——获取版本号
获取版本号:
或者:
- (void)viewDidLoad {
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
NSLog(@"%@",infoDict);
NSString *executableFile = [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleExecutableKey];
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey];
}
打印:
Printing description of dict:
{
CFBundleDevelopmentRegion = en;
CFBundleDisplayName = "\U5168\U7403\U8f66\U5c55\U5feb\U62a5";
CFBundleExecutable = "Palmtrends_qqcz_1.0.0";
CFBundleIconFiles = (
"Icon.png",
"Icon@2x.png",
"Icon-Small.png",
"Icon-Small@2x.png",
"Icon-Small-50.png",
"Icon-Small-50@2x.png",
"Icon-72.png",
"Icon-72@2x.png"
);
CFBundleIdentifier = "com.pal****.qq****";
CFBundleInfoDictionaryVersion = "6.0";
CFBundleName = "\U5168\U7403\U8f66\U5c55\U5feb\U62a5";
CFBundlePackageType = APPL;
CFBundleShortVersionString = "1.0.2";
CFBundleSignature = "????";
CFBundleSupportedPlatforms = (
iPhoneSimulator
);
CFBundleURLTypes = (
{
CFBundleTypeRole = Editor;
CFBundleURLName = "yybj_weixin";
CFBundleURLSchemes = (
wxc53e31e71e69****
);
},
{
CFBundleTypeRole = Editor;
CFBundleURLName = "com.weibo";
CFBundleURLSchemes = (
wb13280****
);
}
);
CFBundleVersion = "1.0.2.1";
DTPlatformName = iphonesimulator;
DTSDKName = "iphonesimulator8.1";
LSRequiresIPhoneOS = 1;
UIDeviceFamily = (
1
);
UIPrerenderedIcon = 1;
UIRequiredDeviceCapabilities = (
armv7
);
UIStatusBarHidden = 1;
UISupportedInterfaceOrientations = (
UIInterfaceOrientationPortrait,
UIInterfaceOrientationLandscapeLeft,
UIInterfaceOrientationLandscapeRight
);
UIViewControllerBasedStatusBarAppearance = 0;
}
获取版本号:
- (void)viewDidLoad { [super viewDidLoad]; //获取版本号 NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"Info" ofType:@"plist"]; NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithContentsOfFile:bundlePath]; NSString *version = [dict objectForKey:@"CFBundleShortVersionString"]; _mVersionLabel.text = version; }
或者:
- (void)viewDidLoad {
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
NSLog(@"%@",infoDict);
NSString *executableFile = [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleExecutableKey];
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey];
}
打印:
Printing description of dict:
{
CFBundleDevelopmentRegion = en;
CFBundleDisplayName = "\U5168\U7403\U8f66\U5c55\U5feb\U62a5";
CFBundleExecutable = "Palmtrends_qqcz_1.0.0";
CFBundleIconFiles = (
"Icon.png",
"Icon@2x.png",
"Icon-Small.png",
"Icon-Small@2x.png",
"Icon-Small-50.png",
"Icon-Small-50@2x.png",
"Icon-72.png",
"Icon-72@2x.png"
);
CFBundleIdentifier = "com.pal****.qq****";
CFBundleInfoDictionaryVersion = "6.0";
CFBundleName = "\U5168\U7403\U8f66\U5c55\U5feb\U62a5";
CFBundlePackageType = APPL;
CFBundleShortVersionString = "1.0.2";
CFBundleSignature = "????";
CFBundleSupportedPlatforms = (
iPhoneSimulator
);
CFBundleURLTypes = (
{
CFBundleTypeRole = Editor;
CFBundleURLName = "yybj_weixin";
CFBundleURLSchemes = (
wxc53e31e71e69****
);
},
{
CFBundleTypeRole = Editor;
CFBundleURLName = "com.weibo";
CFBundleURLSchemes = (
wb13280****
);
}
);
CFBundleVersion = "1.0.2.1";
DTPlatformName = iphonesimulator;
DTSDKName = "iphonesimulator8.1";
LSRequiresIPhoneOS = 1;
UIDeviceFamily = (
1
);
UIPrerenderedIcon = 1;
UIRequiredDeviceCapabilities = (
armv7
);
UIStatusBarHidden = 1;
UISupportedInterfaceOrientations = (
UIInterfaceOrientationPortrait,
UIInterfaceOrientationLandscapeLeft,
UIInterfaceOrientationLandscapeRight
);
UIViewControllerBasedStatusBarAppearance = 0;
}
相关文章推荐
- iOS开发info.plist一些字段含义
- ios开发-程序启动原理&项目中的常见文件(pch文件 & Info.plist)
- iOS开发info.plist一些字段含义
- iOS从info.plist 获取项目的名称及版本号
- Info.plist和pch文件的作用,UIApplication,iOS程序的启动过程,AppDelegate 方法解释,UIWindow,生命周期方法
- ios开发从.plist文件中获取数据
- 关于iOS开发中info.plist文件的解读
- Info.plist和pch文件的作用,UIApplication,iOS程序的启动过程,AppDelegate 方法解释,UIWindow,生命周期方法
- iOS从info.plist 获取项目的名称及版本号
- 【深入浅出IOS开发】Info.plist常见的设置
- iOS开发 iOS9适配(info.plist文件)
- iOS开发常见文件--Info.plist
- 关于iOS开发中info.plist文件的解读
- 【iOS开发-61】更换plist资源后,运行程序iOS模拟器仍然显示上一次数据的样子,怎么解决?
- iOS 代码中获取info.plist文件对应的字典对象
- ios开发之获取程序相关的一些路径方法
- iOS从info.plist 获取项目的名称及版本号
- IOS开发—— 获取AppDelegate的属性或字段
- 【深入浅出IOS开发】Info.plist常见的设置
- IOS开发-OC学习-Info.plist文件解析