I have a view controller (let's call it MainViewController) that contains a UITabBarController, where each TabBarItem connecting to its respective UIViewController-derived classes. For certain UIViewControllers, I want to pass in value at the time via MainViewController. What's the best way to do this proxy'ing?
Right now, I end up having to create a property for proxy purposes in MainViewController. But ideally, I would rather MainViewController not know the specific type of UIViewController it has to pass the value to and the specific type of value that it's passing, since the value is never used in MainViewController, I see the coupling as being unnecessary.
e.g.
Let's say tab bar item 2 connects to UIEmployeeInfoViewController class. And UIEmployeeInfoViewController is interested in an object of type called EmployeeInfo.
Here is my current solution but it's what I am trying to avoid doing in search of a better approach:
1) Somewhere where UIMainViewController is being create... UIMainViewController *mainViewController = [[UIMainViewController alloc] initWith...]; // a property called employeeInfo is created in UIMainViewController class so it can be forwarded later mainViewController.employeeInfo = employeeInfoObj; ... 2) Code to make UIMainViewController pass the employeeInfo along to UIEmployeeInfoViewController when the tabbar item is tapped: - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController { if ([viewController class] == [UIEmployeeInfoViewController class]) { // Need to create coupling to UIEmployeeInfoViewController class // and to EmployeeInfo class as well ((UIEmployeeInfoViewController *)viewController).employeeInfo = self.employeeInfo; } return YES; }