How to add a badge to a UITabBar that is customizable?

Viewed 16878

I am adding a badge to my UITabBarController's UITabBar as such:

UITabBarItem *tbi = (UITabBarItem *)[stTabBarController.tabBar.items objectAtIndex:1];
tbi.badgeValue = @"2";

However, my UITabBarController is customizeable, so the index may change. How can I make sure the badge gets applied to the correct UITabBarItem?

5 Answers
Related