ios 版本更新

-(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];   

   }  

}  

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。