0

I am trying to add badge number in UITabBarController and it is working . But i started NSTimer . when timer completed . it calls webservice and in return i get badge number .

but when i set badge number to UITabBarController in this senario . it is no more working.

Deepesh
  • 8,065
  • 3
  • 28
  • 45
  • Can you include some code with the timer and the connection management please? – Jeremy Apr 16 '13 at 09:13
  • try this UITabBarItem *tbi = (UITabBarItem *)self.tabController.selectedViewController.tabBarItem; tbi.badgeValue = @"2"; – Deepesh Apr 16 '13 at 09:24

2 Answers2

0
[[super.tabBarController.viewControllers objectAtIndex:2] tabBarItem].badgeValue = @"1";
Rushabh
  • 3,208
  • 5
  • 28
  • 51
0

It's hard to tell without seeing your code, but two possibilities spring to mind:

  1. You're trying to set the badge value from a thread that is not the main thread. Try wrapping your badge value setting code in a dispatch_async to the main queue:

    dispatch_async(dispatch_get_main_queue(), ^
    {
        // set badge number    
    });
    
  2. The item that you're setting the badgeValue on is nil. Try adding a breakpoint or some NSLog statements to the line where you add the badge number, and check the value of some of the objects isn't nil.

James Frost
  • 6,960
  • 1
  • 33
  • 42