Search code examples
iosswiftuitabbarcontrolleruitabbar

How to pass data from tab bar controller to each tab before they are loaded?


I am sending an HTTP request to a website, and can there are rate restrictions (5 per minute) so I just want to get the data once when the app opens, (my tab bar controller), and then pass that data to each of my tabs. How would I be able to do this. Thank you


Solution

  • In each tab you have to get the tabBarController reference and using that reference you can access the values.

    MyTabBarController *tabBarObj = (MyTabBarController*)self.tabBarController;
    NSLog(@"%@",tabBarObj.responseValue)