Skip to content

Instantly share code, notes, and snippets.

@MoussaHellal
Created September 1, 2019 21:42
Show Gist options
  • Save MoussaHellal/aa700319ef1dbf5d015b8614bb409d33 to your computer and use it in GitHub Desktop.
Save MoussaHellal/aa700319ef1dbf5d015b8614bb409d33 to your computer and use it in GitHub Desktop.
add the observer
func createObservers() {
NotificationCenter.default.addObserver(self, selector: #selector(TabBarController.setBadge(notification:)), name: addItemNotfication, object: nil)
}
@objc func setBadge(notification: NSNotification) {
//get the existant badge value
let badgeValue = Int(self.tabBar.items![0].badgeValue!)!
// set the new badge value
self.tabBar.items![0].badgeValue = "\(badgeValue + 1)"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment