<写在一个方法中>
- (void)VersionUpdate{
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
CFShow(infoDictionary);
NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager GET:@"https://itunes.apple.com/cn/lookup?id=868722244" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSDictionary *dic = (NSDictionary *)responseObject;
NSArray *arr = [dic objectForKey:@"results"];
NSString *app_NewVersion = [[arr objectAtIndex:0] objectForKey:@"version"];
//判断 然后 弹出 AlertView
if (![app_Version isEqualToString:app_NewVersion]) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"当前版本不是最新版本,是否更新" delegate:self cancelButtonTitle:@"下次更新" otherButtonTitles:@"更新", nil];
[alert show];
[alert release];
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
}];
}