I have 1 main UIViewController that contains a UITabBarController. The tab bar controller has 4 UIViewControllers (each managed by UINavigationControllers). Succinctly, it looks like this:
MainViewController | |--- FirstUIViewController | |--- SecondUIViewController | |--- ThirdUIViewController | |--- FourthUIViewController
The FirstUIViewController is loaded by default.
In the SecondUIViewController, there is an event that can occur. This event has specific data that is passed along with it. When this event occurs I want 2 things to happen:
1) FourthUIViewController to be selected in the tab bar controller to visually show a different tab has been entered.
2) A subsequent action in FourthUIViewController where a specific UITableViewCell is selected. The selected cell is determined by the data that is passed along in the event.
In order to do this, I've created an NSNotification observer in the MainViewController. It listens for the event from the SecondUIViewController and gets data from it via userInfo.
I also know that from MainViewController I can easily set the selectedIndex on the UITabBarController in order to have the correct tab shown. (#1 accomplished).
However, accomplishing #2 baffles me. I don't know how to (properly, correctly) set the selectedIndex of the tab bar and then have the FourthUiViewController act upon a selected cell. My assumption is that FourthUIViewController may not have been loaded before this event occurs so I couldn't set any parameters or call any observers.
Perhaps the broader question is how data can be passed when loading a UIViewController through tab selection (compared to pushing a new UIViewController which is very straightforward).
TIA.