0

I have 2 UIViewController

1- UIViewController with UICollectionView. In cell I have UIButton and UILabel. When I press UIButton I have save text from UILabel to UserDefaults array. (Main screen)

2- UIViewController

When I launch the app I want to tap the UIButton in cell and show the badge with array.count (for example I tap on 3 different Button and array have 3 count) on second Tab Bar Item

Im tried to do this through the protocol in UICollectionViewCell class and add the extension to UIViewController with CollectionView

Andrew0
  • 37
  • 1
  • 8

1 Answers1

0

In collection ViewController at didSelectItemAtIndexPath or at any part of code that you need to change secondViewcontroller Tabbar badge

Just do this

func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath){

 if let tabItems = self.tabBarController?.tabBar.items
        {
            // In this case we want to modify the badge number of the seond tab:
            let tabItem = tabItems[1]
            tabItem.badgeValue = "1" // set count you need
        }
}
Abdelahad Darwish
  • 5,969
  • 1
  • 17
  • 35