-(void)checkAppUpdate { NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary]; NSString *nowVersion = [infoDict objectForKey:@"CFBundleVersion"]; NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://itunes.apple.com/lookup?id=%@", JWversionNumber]]; NSString * file = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil]; NSRange substr = [file rangeOfString:@"\"version\":\""];//判斷是否是找到字符 NSRange range1 = NSMakeRange(substr.location+substr.length,10); NSRange substr2 =[file rangeOfString:@"\"" options:nil range:range1]; NSRange range2 = NSMakeRange(substr.location+substr.length, substr2.location-substr.location-substr.length); NSString *newVersion =[file substringWithRange:range2]; if(![nowVersion isEqualToString:newVersion] && newVersion !=nil) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"版本有更新"delegate:self cancelButtonTitle:@"取消"otherButtonTitles:@"更新",nil]; alert.tag = 222; [alert show]; }else{ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"已是最新版本"delegate:self cancelButtonTitle:@"肯定"otherButtonTitles:nil,nil]; alert.tag = 222; [alert show]; } }