#define kStoreAppId @“xxxxxxxxx” // (appid数字串)

-(void)checkAppUpdate {

NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];

NSString *nowVersion = [infoDict objectForKey:@"CFBundleVersion"];

NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://itunes.apple.com/lookup?id=%@", kStoreAppId]];

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]) {

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"版本有更新"delegate:self cancelButtonTitle:@"取消"otherButtonTitles:@"更新",nil]; [alert show];

}

}

- (void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex

{

if(buttonIndex==1)

{ // 此处加入应用在app store的地址,方便用户去更新,一种实现方式如下:

NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://itunes.apple.com/us/app/id%@?ls=1&mt=8", kStoreAppId]];

[[UIApplication sharedApplication] openURL:url]; } }

最新文章

  1. .NET Core RC2/RTM 明确了时间表
  2. [LeetCode] Candy 分糖果问题
  3. NopCommerce 增加 Customer Attributes
  4. python成长之路【第十四篇】:HTML初步认识
  5. ubuntu 下更新PHP版本 ZT
  6. Linux_03------Linux的基本命令
  7. SDUT1479数据结构实验之栈:行编辑器
  8. codeforces300A Array
  9. Java基础知识强化之IO流笔记58:内存操作流
  10. json 序列化的两种方式
  11. C# 的sql server like 的参数
  12. SSH框架完全整合
  13. STL 贺习笔记
  14. Laravel - Union + Paginate at the same time? and another problem----1222 The used SELECT statements have a different number of columns (SQL: (select count(*) as aggregate from
  15. openstack 之~keystone基础
  16. Django基本配置与URLconf
  17. stm32最简单的实现BootLoader
  18. 自定义Exception:MVC抛出自定义异常,并以Json方式返回
  19. Azure SQL 数据库仓库Data Warehouse (2) 架构
  20. 深入出不来nodejs源码-从fs.stat方法来看node架构

热门文章

  1. SqlServer创建数据表描述及列描述信息
  2. Python高手之路【十】python基础之反射
  3. 【成长之路】【python】python基础1
  4. [UWP小白日记-10]程序启动屏(ios解锁既视感)
  5. cache数据库学习周结
  6. centos搭建svn服务器
  7. C#深复制与浅复制
  8. Kafka发送消息失败原因
  9. <hdu - 1232> 畅通工程 并查集问题 (注意中的细节)
  10. java操作mongodb——连接数据库