I can't seem to add a badge on a TabBarItem
Tried a lot of options (that's why the code is splitted into variables).
Thought it had something to do with the treading so the update is back on the main thread, still nothing.
The code:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSInteger badge_count = 0;
badge_count = getDataFromServer();
if (snacks_count > 0)
{
MainTabBarViewController *c = [self.storyboard instantiateViewControllerWithIdentifier:@"tabBarController"];
UINavigationController *nav = [c.viewControllers objectAtIndex:1];
dispatch_async(dispatch_get_main_queue(), ^{
nav.tabBarItem.badgeValue = [NSString stringWithFormat:@"%ld", (long)badge_count];
});
}
});