In some of our apps, we need user to notify that something new happened to a particular section of the app.Suppose our app has three tabs and one of the tab name is New Offers.
So for the users, to recognize instantly that new offers are available we set a icon or badge to our tab.To set the badge for a tab you have to write a single line of code in which you have to pass the tab index(index of tab where you want to show the badge) and badge Value (number to display inside badge, )
[[[[[self tab] tabBar] items] objectAtIndex:1] setBadgeValue:@”2″];
Here, tab is our UITabBarController, and we are showing badge in our second tab with a value 2.
And to reset the badge, write the line
[[[[[self tab] tabBar] items] objectAtIndex:1] setBadgeValue:nil];