title: Delay in updating Tab Bar Item's Badge Value
body: <p>I have a function which runs every 5 seconds to check for new messages, if a new message is triggered I'm updating the badge value of the tab bar item using the below code</p>
  
  <pre><code>    NSString *chkUrl = @"http://domain.com/script.php";
      NSURL *url = [[[NSURL alloc] initWithString:chkUrl] autorelease];
      NSError *error = nil;
      NSStringEncoding encoding;
      NSString *returnHTML = [[NSString alloc] initWithContentsOfURL:url usedEncoding:&amp;encoding error:&amp;error];
  
      int totalNewMessages = [[returnHTML stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] intValue];
      AppDelegate *mainDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  
      NSLog(@"badge before:%@",[[mainDelegate.tabBarController.viewControllers objectAtIndex:2] tabBarItem].badgeValue);
      [[mainDelegate.tabBarController.viewControllers objectAtIndex:2] tabBarItem].badgeValue = [NSString stringWithFormat:@"%d",totalNewMessages];
      NSLog(@"badge after:%@",[[mainDelegate.tabBarController.viewControllers objectAtIndex:2] tabBarItem].badgeValue);
  </code></pre>
  
  <p>The problem is the badge value is not updating immediately! Maybe in the third of fourth call it will be updated! Anything wrong I'm doing! Or is it a bug in iOS!</p>
  
  <p>As a work around, I repeated the above line 10 times on every update, but again it's not updating, so the problem is a delay in updating the badge value, it's not a matter of re-run the update line!</p>
  
  <p>BTW, this problem is taking place in both Xcode 4.6 Simulator &amp; my iPhone 5 with iOS 6.1</p>