I have an app that has a navigation controller in a tabbar controller. The root for the navigation controller is a table view controller. The table view has a segue to an image view. I want to update the badge value on a tab from the image view controller. From the tabbar controller, this works fine:
UIViewController *viewController = [self.tabBarController.viewControllers objectAtIndex:1];
viewController.tabBarItem.badgeValue = @"x";
But when I put the same code into the imageview controller, it doesn’t work. When I check the value of ‘viewController’ after it executes, the value is nil. Same for self.tabBarController. For some reason the image view controller can’t see its tabbarcontroller.
so there are many ways to do this but the best way would be subcscribe to an NSNotification and then from your image view or wherever, make that notification so it would look something like.
And then in you deeper items such as the imageview or whatever you post it like this
And then you get the information from the userInfo like so in you method that changes the badge value