【iOS】获取应用版本和语言
来源:互联网 发布:linux mesg 编辑:程序博客网 时间:2024/06/05 09:11
一.获取应用版本
方式一:通过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】获取应用版本和语言
- iOS 获取应用版本
- 获取应用的版本名和版本
- 获取iOS应用当前版本宏定义
- IOS 获取设备机型 系统版本 应用版本
- IOS获取设置的语言和国家以及设备的名称版本
- 获取apk和应用的版本
- js获取Android和iOS的版本
- IOS 判断应用版本和升级提示
- IOS 判断应用版本和升级提示
- IOS 判断应用版本和升级提示
- IOS 判断应用版本和升级提示
- IOS 判断应用版本和升级提示
- [ios]获取app版本更新检测的不同语言信息
- 【iOS开放】应用从App Store获取版本信息
- iOS开发 获取应用名称和版本号
- iOS获取应用和设备信息
- 获取IOS App版本
- ScrollView嵌套Listview或GridView
- 通过概率规划归纳的人类水平概念学习
- Android静默安装实现方案,仿360手机助手秒装和智能安装功能
- 如何利用自己的电脑做服务器发布tomcat的WEB项目供外网访问
- git最细致的图文教程
- 【iOS】获取应用版本和语言
- os的组成
- 第12周项目5 迷宫问题之图深度优先遍历解法
- 在线微信编辑器(构思编辑器)——如何让微信公众号文章图文设计更完美
- LeetCode 231:Power of Two
- AsyncHttpClient
- 《Getting Real》书摘
- HDU 2571 路径权值最大 dp
- APS.NET MVC 过滤器