AFNetWorking 判断当前版本是否是最新版本

时间:2023-03-09 00:25:35
AFNetWorking 判断当前版本是否是最新版本

NSString *url = [[NSString alloc] initWithFormat:@"http://itunes.apple.com/lookup?id=%@",@"***"];

[self reqeautDataUrl:url parma:nil block:^(NSDictionary *dataDic, NSError *error) {

[self hideHud];

if(error){

[self showAlertView:@"版本获取失败"];

return ;

}

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

NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];

if([[dataDic objectForKey:@"version"] isEqualToString:app_Version]){

UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:@"提示" delegate:nil cancelButtonTitle:@"确定" destructiveButtonTitle:@"已经是最新版本" otherButtonTitles:nil, nil];

[actionSheet showInView:self.view];

}else {

UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:@"提示" delegate:nil cancelButtonTitle:@"确定" destructiveButtonTitle:@"请更新最新的版本" otherButtonTitles:nil, nil];

[actionSheet showInView:self.view];

}

}];