码迷,mamicode.com
首页 > 移动开发 > 详细

ios 版本更新

时间:2015-05-26 22:45:54      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:

-(void)GetUpdate  

{  

    NSString *nowVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];  

    NSString * file =  [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://itunes.apple.com/lookup?id=***"]];  

    NSLog(file);  

   //"version":"1.0"  

    NSRange substr = [file rangeOfString:@"\"version\":\""];  

    NSRange substr2 =[file rangeOfString:@"\"" options:NULL range:NSRange{substr.location+substr.length,10}];  

    NSRange range = {substr.location+substr.length,substr2.location-substr.location-substr.length};  

    NSString *newVersion =[file substringWithRange:range];  

    if([nowVersion isEqualToString:newVersion]==NO)  

    {  

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

        [alert show];  

    }  

      

}  

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

{  

   if(buttonIndex==1)  

   {  

       NSURL *url = [NSURL URLWithString:@"https://itunes.apple.com/us/app/qun-xiang-dao/id***?ls=1&mt=8"];  

       [[UIApplication sharedApplication]openURL:url];   

   }  

}  

 

ios 版本更新

标签:

原文地址:http://www.cnblogs.com/huangzs/p/4531725.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!