I have a tab bar project with one tab in the beginning and the view controller has buttons. If a button is tapped - a specific view controller is expected to be added to the tabbarcontroller/tab items. But each time I press the button the same viewcontroller/tab item is being added (multiple tab items of the same). I am trying to limit one tab item for one Viewcontroller, regardless how many times the button is tapped. Any help would be appreciated.
-(IBAction) buttontap:id(sender){
UITableViewController*TableView = [mainStoryBoard instantiateViewControllerWithIdentifier:@"Table A"];
TableView.title = @"Table A";
NSMutableArray *TabBarItems = [NSMutableArray arrayWithArray:self.tabBarController.viewControllers];
if ([self.tabBarController.tabBarItem.title.description isEqualToString:@"Table A"])
{
[TabBarItems addObject:nil];
}
else
{
[TabBarItems addObject:TableView];
TableView.tabBarItem.image = [UIImage imageNamed:@"contents.png"];
}
[self.tabBarController setViewControllers:TabBarItems];
}