views:

665

answers:

1

Hi, I have a UITabBarController,

How can I create/update the badge value of the tabBar item from my viewController ?

The tabBar item's created in the ib.

I connected the tabBar item to the controller using an IBOutlet UITabBar *tabBar.

thanks.

+1  A: 

If your viewcontroller already has a tab bar controller associate with it, you can just drill down to the tab bar item and set its badge, like this:

[[[[[self tabBarController] tabBar] items] 
                   objectAtIndex:tabIndex] setBadgeValue:badgeValueString];

where tabIndex is the index of the tab item you want to set and badgeValueString is the string value you want to set on the tab.

Matt Long
great, thank you!
omri