Created
September 1, 2019 21:42
-
-
Save MoussaHellal/aa700319ef1dbf5d015b8614bb409d33 to your computer and use it in GitHub Desktop.
add the observer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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