Code snippet:
self.tabBarController?.tabBar.items?[2].badgeValue = "999"
The code above works, but my tab bar badge updates only when I scroll (interact with) the view. Any thoughts?
The badgeValue is updated whenever I add or remove an item from a shopping bag. This function is in the Bag class:
func adicionarProduto(idProduto : Int){
produtos.append(idProduto) self.tabBarController?.tabBar.items?[2].badgeValue = String(sacola.produtos.count)
}
Thanks!