0

An app has a set of screens (tabs) configured with the UITabBarController.
Each tab has own UINavigationController instance.
Each UINavigationBar has a button with dropdown. Selecting a row in a dropdown should trigger a contentReload event in some of the UIViewControllers and update the UINavigationBars.

What is the best way to synchronize multiple tabs of the app? I have multiple options in mind:

  1. An Observer pattern: create a State class to store the shared state (what item is currently selected) and propagate it to all of the observers

  2. Use NotificationCenter and subscribe all the relevant objects to the changes.

  3. Share an instance of State between all of the controllers, monitor changes using KVO.

Should there be any preference to one method over another? Or is there any standard pattern of handling such app state transitions?

Example of the UI, the dropdown is accessible on every controller: enter image description here

Richard Topchii
  • 7,075
  • 8
  • 48
  • 115

0 Answers0