zoukankan      html  css  js  c++  java
  • 2016-02-22 版本更新

    • didfinishlauch  appdelegate 中

       

        // 01  gzz022 版本更新 

        [self VersionButton];

        

    //02    gzz0222 提示自动更新

    -(void)VersionButton{

        NSString  *string=[NSString stringWithContentsOfURL:[NSURL URLWithString:@"https://itunes.apple.com/lookup?id=1079728205"] encoding:NSUTF8StringEncoding error:nil];

        if (string!=nil &&[string length]>0&&[string rangeOfString:@"version"].length==7 ) {

            [self checkUpAppUpdate:string];

        }

       

    }

    //03   gzz0222

    -(void)checkUpAppUpdate:(NSString *)appInfo{

     //获取当前版本

    //    NSString *version=[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];//CFBundleShortVersionString

        

        NSString *version=[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];//CFBundleShortVersionString

        NSString  *appInfo1=[appInfo substringFromIndex:[appInfo rangeOfString:@""version":"].location+10];

        

        appInfo1=[[appInfo1 substringToIndex:[appInfo1 rangeOfString:@","].location]stringByReplacingOccurrencesOfString:@""" withString:@""];

        

        //判断,如果当前版本与发布的版本不相同,则进入更新.如果相等,那么当前版本就是最新版本

        

    //    NSString *ver2=@"2.0";

        

        if (![appInfo1 isEqualToString:version]) {

            NSLog(@"%@ 新版本,%@当前版本",appInfo1,version);

            UIAlertView  *alert=[[UIAlertView alloc]initWithTitle:@"" message:[NSString stringWithFormat:@"新版本 %@ 已发布!",appInfo1] delegate:self.class cancelButtonTitle:@"稍后更新" otherButtonTitles:nil, nil];

            alert.delegate=self;

            [alert addButtonWithTitle:@"前往更新"];

            [alert show];

            

            alert.tag=20019;

            

        }else{

    //       UIAlertView  *alll= [[UIAlertView  alloc]initWithTitle:nil message:@"已是最高版本!" delegate:self.class cancelButtonTitle:@"知道啦!" otherButtonTitles:nil ,nil];

    //

    //        [alll show];

        

        }

    }

    //alertview代理 

    - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex{

        if (alertView.tag==20019&&buttonIndex==1) {

            NSString  *strUrl=[NSString stringWithFormat:@"https://itunes.apple.com/cn/app/gan-dan-xiang-zhao/id1079728205?mt=8"];

            

            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:strUrl]];

        }

    }

  • 相关阅读:
    【算法•日更•第二十七期】基础python
    【算法•日更•第二十六期】非常基础的数论
    【算法•日更•第二十五期】万能算法(一):搜索+?
    【算法•日更•第二十四期】二分查找和二分答案的区别
    Hadoop学习9--动态增加datanode
    java-Spring-1
    Hadoop学习6--里程碑式的开始之执行第一个程序wordcount
    Hadoop学习5--配置本地开发环境(Windows+Eclipse)
    Hadoop学习4--安装Hadoop
    Hadoop学习3--安装ssh服务
  • 原文地址:https://www.cnblogs.com/gzz2016/p/5207417.html
Copyright © 2011-2022 走看看