Created
March 24, 2017 13:48
-
-
Save songxing10000/fa36dd8aac320f8e0327f0f466aa684c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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