怎么判断app是否有最新版本需要前往下载

    NSString *url= @"http://itunes.apple.com/lookup?id=616584641";
    NSData *data1 = [NSData dataWithContentsOfURL:[NSURL URLWithString:url]];
    
    NSString  *content = [[[NSString alloc] initWithBytes:[data1 bytes] length:[data1 length] encoding:NSISOLatin1StringEncoding] autorelease];
    
    NSString *jsonStr = [[NSString alloc] initWithFormat:@"%@",content];
    SBJSON *json = [[SBJSON alloc] init];
    NSDictionary *jsonDic = [json objectWithString:jsonStr error:nil];
    NSDictionary  *Info = [[jsonDic objectForKey:@"results"] objectAtIndex:0];
    NSString *latestVersion = [Info objectForKey:@"version"];
    self.trackViewUrl = [Info objectForKey:@"trackViewUrl"];
    NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
    NSString *currentVersion = [infoDict objectForKey:@"CFBundleVersion"];
    SYAppDelegate *app = (SYAppDelegate*)[[UIApplication sharedApplication] delegate];
    app.currentVersion = currentVersion;
    app.latestVersion = latestVersion;
    if ([currentVersion floatValue] < [latestVersion floatValue]) {
        UIAlertView  *alter = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"最新版本%@已经发布", latestVersion]
                                                         message:@"是否前往下载"
                                                        delegate:self
                                               cancelButtonTitle:@"取消"
                             

你可能感兴趣的:(怎么判断app是否有最新版本需要前往下载)