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 UIViewController
s and update the UINavigationBar
s.
What is the best way to synchronize multiple tabs of the app? I have multiple options in mind:
An Observer pattern: create a
State
class to store the shared state (what item is currently selected) and propagate it to all of the observersUse
NotificationCenter
and subscribe all the relevant objects to the changes.Share an instance of
State
between all of the controllers, monitor changes usingKVO
.
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: