Skip to content

Instantly share code, notes, and snippets.

@songxing10000
Created March 24, 2017 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save songxing10000/fa36dd8aac320f8e0327f0f466aa684c to your computer and use it in GitHub Desktop.
Save songxing10000/fa36dd8aac320f8e0327f0f466aa684c to your computer and use it in GitHub Desktop.
[BaseService postJSONWithUrl:APP_URL parameters:nil success:^(id responseObject)
{
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil removingNulls:YES ignoreArrays:NO];
NSArray *infoArray = [dic objectForKey:@"results"];
if ([infoArray count])
{
NSDictionary *releaseInfo = [infoArray objectAtIndex:0];
NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];
NSString *currentVersion = [[infoDic objectForKey:@"CFBundleShortVersionString"] stringByReplacingOccurrencesOfString:@"." withString:@""];
NSString *lastVersion = [[releaseInfo objectForKey:@"version"] stringByReplacingOccurrencesOfString:@"." withString:@""];
CGFloat fLast = [lastVersion intValue] > 100 ? [lastVersion intValue] : [lastVersion intValue]*10;
CGFloat fCurrent = [currentVersion intValue] > 100 ? [currentVersion intValue] : [currentVersion intValue]*10;
if (fLast>fCurrent)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"更新" message:@"有新的版本更新,是否前往更新?" delegate:__self cancelButtonTitle:@"关闭" otherButtonTitles:@"更新", nil];
alert.tag = 100;
[alert show];
}
}
} fail:^(NSError *error)
{
DLog(@"获取失败");
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment