UIBarButtonItem-Badge
UIBarButtonItem-Badge copied to clipboard
The value cannot be updated immediately
swift code:
self.navigationItem.rightBarButtonItem?.badgeValue = "\(count)"
First time it can be updaed immediately. When the value changed the view only be updated after a few seconds.
It updated after about 7 seconds in rootviewconroller. But it even doen't work in pushed viewcontroller when the value changed.
My mistake, message reception is asynchronous communication.
DispatchQueue.main.async { [weak self]() -> Void in self?.navigationItem.leftBarButtonItem?.badgeValue = "\(count)" }
it's okay.