Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. [BaseService postJSONWithUrl:APP_URL parameters:nil success:^(id responseObject)
  2. {
  3. NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil removingNulls:YES ignoreArrays:NO];
  4. NSArray *infoArray = [dic objectForKey:@"results"];
  5. if ([infoArray count])
  6. {
  7. NSDictionary *releaseInfo = [infoArray objectAtIndex:0];
  8. NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];
  9. NSString *currentVersion = [[infoDic objectForKey:@"CFBundleShortVersionString"] stringByReplacingOccurrencesOfString:@"." withString:@""];
  10. NSString *lastVersion = [[releaseInfo objectForKey:@"version"] stringByReplacingOccurrencesOfString:@"." withString:@""];
  11. CGFloat fLast = [lastVersion intValue] > 100 ? [lastVersion intValue] : [lastVersion intValue]*10;
  12. CGFloat fCurrent = [currentVersion intValue] > 100 ? [currentVersion intValue] : [currentVersion intValue]*10;
  13. if (fLast>fCurrent)
  14. {
  15. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"更新" message:@"有新的版本更新,是否前往更新?" delegate:__self cancelButtonTitle:@"关闭" otherButtonTitles:@"更新", nil];
  16. alert.tag = 100;
  17. [alert show];
  18.  
  19. }
  20. }
  21. } fail:^(NSError *error)
  22. {
  23. DLog(@"获取失败");
  24. }];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement