There are few ViewControllers in my app and all of them have menu button. When this button is pressed - menu ViewController is opened.
I want to mark menu button with red dot showing that some new content is available and user need to press menu button to see which one of menu item is marked with this dot.
As all my buttons are independent of each other - I thought that I need to solve it this way
But maybe there is some more elegant way?
use NotificationCenter to notify the ui when new content available
in the menu viewcontroller class:
//put this in viewDidLoad
NotificationCenter.default.addObserver(self.selector : #selector(menuviewcontroller.refresh(_:)),name:NSNotification.Name(rawValue:"showRedBtn"),object : nill)
//create function refresh
func refresh(_ notification : Notification)
{
//make the red dot visible
}
create class that listen if any content added and call the delegate in case of add by this line of code
NotificationCenter.default.post(name : Notification.Name("showRedBtn"),object : nil , userInfo : nil)
hope it's will help you