0

I have 2 controllers [TableViewController, SecondViewController]. On my TableViewController I have badges and I update them from my SecondViewController, but when I update my badge count from the SecondVC it doesn't refreshes on TableVC, for this I need to change my screen or pull up my controller and just after that it refreshes my badge view.

I tried this, in SecondVC when I update badge count:

badgeCount++
TableViewController().tableView.reloadData()

Also, this:

badgeCounter++
dispatch_async(dispatch_get_main_queue(), { () -> Void in
    TableViewController().tableView.reloadData()
})

but in both cases it doesn't update my badge view. For this I need just change controllers/screens or pull up my TableVC.

How can I fix this?

And one interesting thing, when I set the timer, which updates my TableVC every second, in this case my badge counter view updates well =/

Orkhan Alizade
  • 7,379
  • 14
  • 40
  • 79

1 Answers1

0

You can use notifications , the second view controller will notify the table view controller of bundle change. When you receive the notification form second view controller you can reload it. You also can pass the data in notification using userInfo.

Or do it with delegates where you table view controller will be the delegate of the second view controller.

Community
  • 1
  • 1
Oleh Kudinov
  • 2,533
  • 28
  • 30