【iOS】获取应用版本和语言
2015-12-14 11:46
405 查看
一.获取应用版本
方式一:通过APPID获取
这种方式需要使用的应用的ID号,从网络获取.
方式二:本地获取
2015-12-14 11:32:55.857 MVC[27108:1935670] {
BuildMachineOSBuild = 15B42;
CFBundleDevelopmentRegion = en;
CFBundleExecutable = MVC;
CFBundleIdentifier = "zhuming3834.sina.com";
CFBundleInfoDictionaryVersion = "6.0";
CFBundleInfoPlistURL = "Info.plist -- file:///Users/myhg/Library/Developer/CoreSimulator/Devices/B18BEA3B-03D9-45D1-A892-3E7E182DC345/data/Containers/Bundle/Application/91DB3FC8-01B0-4D8B-B52D-559C798B3B68/MVC.app/";
CFBundleName = MVC;
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.1";
DTSDKBuild = 13B137;
DTSDKName = "iphonesimulator9.1";
DTXcode = 0711; // Xcode版本
DTXcodeBuild = 7B1005;
LSRequiresIPhoneOS = 1;
MinimumOSVersion = "9.1"; //iOS版本
UIDeviceFamily = (
1
);
UILaunchStoryboardName = LaunchScreen;
UIMainStoryboardFile = Main;
UIRequiredDeviceCapabilities = (
armv7
);
UISupportedInterfaceOrientations = ( // 横竖屏
UIInterfaceOrientationPortrait,
UIInterfaceOrientationLandscapeLeft,
UIInterfaceOrientationLandscapeRight
);
}
2015-12-14 11:32:55.857 MVC[27108:1935670]
应用版本: 1.0
二.获取应用语言
2015-12-14 11:32:55.855 MVC[27108:1935670]
展示语言: 中文(简体、美国)
2015-12-14 11:32:55.856 MVC[27108:1935670]
当前语言: zh
2015-12-14 11:32:55.856 MVC[27108:1935670]
系统支持的语言: (
"zh-Hans-US",
"en-US"
)
2015-12-14 11:32:55.856 MVC[27108:1935670]
当前语言: zh-Hans-US
方式一:通过APPID获取
这种方式需要使用的应用的ID号,从网络获取.
/** * 获取版本号 * * @param block 获取成功时,返回版本号 * @param err 网络错误时执行的回调 */ +(void)getVersion:(strBlock)block err:(errBlock)err{ NSString *url = [NSString stringWithFormat:@"http://itunes.apple.com/lookup?id=%@",APP_STORE_ID]; // APP_STORE_TD 应用的ID号 //网络管理者对象 AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; manager.responseSerializer = [AFHTTPResponseSerializer serializer]; //发送GET请求 [manager GET:url parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) { NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil]; if (dic[@"results"][0][@"version"]) { block(dic[@"results"][0][@"version"]);//获取版本号 } } failure:^(AFHTTPRequestOperation *operation, NSError *error) { err(); }]; }
方式二:本地获取
// 获取应用版本 NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]; NSLog(@"%@",[[NSBundle mainBundle] infoDictionary]); NSLog(@"应用版本: %@",version);
2015-12-14 11:32:55.857 MVC[27108:1935670] {
BuildMachineOSBuild = 15B42;
CFBundleDevelopmentRegion = en;
CFBundleExecutable = MVC;
CFBundleIdentifier = "zhuming3834.sina.com";
CFBundleInfoDictionaryVersion = "6.0";
CFBundleInfoPlistURL = "Info.plist -- file:///Users/myhg/Library/Developer/CoreSimulator/Devices/B18BEA3B-03D9-45D1-A892-3E7E182DC345/data/Containers/Bundle/Application/91DB3FC8-01B0-4D8B-B52D-559C798B3B68/MVC.app/";
CFBundleName = MVC;
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.1";
DTSDKBuild = 13B137;
DTSDKName = "iphonesimulator9.1";
DTXcode = 0711; // Xcode版本
DTXcodeBuild = 7B1005;
LSRequiresIPhoneOS = 1;
MinimumOSVersion = "9.1"; //iOS版本
UIDeviceFamily = (
1
);
UILaunchStoryboardName = LaunchScreen;
UIMainStoryboardFile = Main;
UIRequiredDeviceCapabilities = (
armv7
);
UISupportedInterfaceOrientations = ( // 横竖屏
UIInterfaceOrientationPortrait,
UIInterfaceOrientationLandscapeLeft,
UIInterfaceOrientationLandscapeRight
);
}
2015-12-14 11:32:55.857 MVC[27108:1935670]
应用版本: 1.0
二.获取应用语言
// 当前所在地信息 NSLocaleIdentifier NSString *identifier = [[NSLocale currentLocale] localeIdentifier]; NSString *displayName = [[NSLocale currentLocale] displayNameForKey:NSLocaleIdentifier value:identifier]; NSLog(@"展示语言: %@", displayName); // 当前所在地的使用语言 NSLocale *currentLocale = [NSLocale currentLocale]; NSLog(@"当前语言: %@", [currentLocale objectForKey:NSLocaleLanguageCode]); // 系统语言 NSArray *languages = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"]; NSLog(@"系统支持的语言: %@",languages); //系统支持的语言 NSString *locLang = [languages objectAtIndex:0]; // 当前语言 NSLog(@"当前语言: %@",locLang);
2015-12-14 11:32:55.855 MVC[27108:1935670]
展示语言: 中文(简体、美国)
2015-12-14 11:32:55.856 MVC[27108:1935670]
当前语言: zh
2015-12-14 11:32:55.856 MVC[27108:1935670]
系统支持的语言: (
"zh-Hans-US",
"en-US"
)
2015-12-14 11:32:55.856 MVC[27108:1935670]
当前语言: zh-Hans-US
相关文章推荐
- ios开发不能错过的xcode插件
- iOS开发之AFNetworking使用
- iOS开发根本布景介绍
- iOS多线程(转)
- iOS 开发小技巧
- 项目适配iOS9遇到的一些问题及解决办法
- IOS开发 短信发送
- iOS开发之OCR光学识别储蓄卡以及信用卡
- iOS 开发NSPredicate,谓词过滤。用于搜索、查询。
- IOS基础
- iOS 9功能
- iOS生命周期
- iOS +AFNetworking2.0+webservice+soap
- iOS opencv
- 「转载」94个iOS开发资源推荐,帮你加速应用开发
- ios 数组排序-高级排序
- iOS开发-Certificates、Identifiers和Profiles详解
- iOS语音播放之切换听筒和扬声器的方法解决方案
- iOS 自定义步骤进度条
- ios tableviewcell footview 不跟着移动