iOS 检测新版本
2016-03-30 15:05
417 查看
-(void)checkAppUpdate { NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary]; NSString *nowVersion = [infoDict objectForKey:@"CFBundleVersion"]; NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://itunes.apple.com/lookup?id=%@", JWversionNumber]]; NSString * file = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil]; NSRange substr = [file rangeOfString:@"\"version\":\""];//判断是不是找到字符 NSRange range1 = NSMakeRange(substr.location+substr.length,10); NSRange substr2 =[file rangeOfString:@"\"" options:nil range:range1]; NSRange range2 = NSMakeRange(substr.location+substr.length, substr2.location-substr.location-substr.length); NSString *newVersion =[file substringWithRange:range2]; if(![nowVersion isEqualToString:newVersion] && newVersion !=nil) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"版本有更新"delegate:self cancelButtonTitle:@"取消"otherButtonTitles:@"更新",nil]; alert.tag = 222; [alert show]; }else{ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"已经是最新版本"delegate:self cancelButtonTitle:@"确定"otherButtonTitles:nil,nil]; alert.tag = 222; [alert show]; } }
相关文章推荐
- iOS 之国际化语言切换
- iOS中仅当视屏全屏播放时支持视屏旋转
- iOS开发——modifying the autolayout engine from a background thread
- 详解iOS应用开发中使用设计模式中的抽象工厂模式
- IOS蓝牙4.0使用心得
- 整理苹果官网上iOS的各种辅助功能
- RevealiOS使用教程之简易配置:不修改您的Xcode工程并加载Reveal
- iOS之9.3真机适配-Could not find Developer Disk Image问题
- 实例解析设计模式中的外观模式在iOS App开发中的运用
- 整理常用iOS的第三方框架
- Windows7上使用VMWare搭建IOS开发环境
- 你真的了解iOS代理设计模式吗?
- iOS Provisioning Profile(Certificate)与Code Signing详解
- iOS扩展是指与一些热门或常见的范例
- iOS开发之解析XML数据
- iOS沙盒清除缓存
- iOS9 访问通讯录
- IOS-59-解决错误:linker command failed with exit code 1 (use -v to see invocation)
- iOS quartzCore第三章——CAEmitterLayer和CAEmitterCell详解
- 设计模式开发中的备忘录模式在iOS应用开发中的运用实例