码迷,mamicode.com
首页 > 其他好文 > 详细

更新版本

时间:2015-07-28 18:14:32      阅读:104      评论:0      收藏:0      [点我收藏+]

标签:

-(void)xinban{

    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];

    NSString *string=@"993071546";

    [request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://itunes.apple.com/lookup?id=%@",string]]];

    [request setHTTPMethod:@"GET"];

    NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];

    NSDictionary *jsonData = [NSJSONSerialization JSONObjectWithData:returnData options:0 error:nil];

    

    NSArray *arry=[jsonData objectForKey:@"results"];

    NSString *appstrorebanben=[[arry objectAtIndex:0] objectForKey:@"version"];

    

    self.trackViewUrl1= [[arry objectAtIndex:0] objectForKey:@"trackViewUrl"];//地址trackViewUrl

    NSUserDefaults * setting = [NSUserDefaults standardUserDefaults];

    

    if (![[setting objectForKey:@"appstrore"] isEqualToString:appstrorebanben]) {

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

        NSString  *currntbanben=[dict objectForKey:@"CFBundleVersion"];

        

        if (![currntbanben isEqualToString:appstrorebanben] ) {

            UIAlertView* view = [[UIAlertView alloc] initWithTitle:@"提示" message:@"啊哦,发现有新版本哦,赶快升级吧!" delegate:self cancelButtonTitle:@"先不要啦" otherButtonTitles:@"立即升级", nil];

            [view show];

            [setting setObject:appstrorebanben forKey:@"appstrore"];

        }

    }

}

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

    if (buttonIndex == 1) {

        // 弹出AppStore更新界面

        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",self.trackViewUrl1]]];

    }

}

 

更新版本

标签:

原文地址:http://www.cnblogs.com/106dapeng/p/4683307.html

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