How do I insert state into a view manager that appears as a child of a UITabBarController? I have two sibling tabs that display information for the selected day. You can change which day is selected on the TextView tab or on the GraphView tab, and I want both tabs to sync, so I don't confuse the user.
One fairly simple way would be to declare a global state variable to hold currentDate, and each currentDate view control in -viewWillAppear :.
But all the tips say not to make global ones (or equivalents, such as general singletones or properties in the applicationβs deletion). Instead, you should inject dependencies so that each controller gets a reference to the general state object. But when / how do you do it? Typically, the UITabBarController does not load its tabs until the user asks them to view them. I donβt think I want to preload everything in-app: didFinishLaunchingWithOptions :, slowing down the launch of the application. But the UITabBarController does not seem to provide any -tabWillAppear event to connect, so I seem to keep currentDate global.
Am I missing something? Thanks.
source share