Charles Black
Charles Black

Reputation: 143

Swift: How do I load Firebase data before a viewController is instantiated?

The root view of my application is a UITabBarController.

In the second tab I have a UICollectionView which is loading data from Firebase inside viewDidLoad.

I am trying to set the badgeValue for the second tabBar item based on the data inside that viewController, but the data isn't loaded until the second tab bar is tapped.

How do I load data for the second viewController before it is instantiated? Should I be loading it somewhere else?

Upvotes: 0

Views: 499

Answers (1)

vivek bhoraniya
vivek bhoraniya

Reputation: 1535

If you want to set badgeValue when application starts or from another controller then you need to call API/Webservice in global method like from Appdelegate or any shared instance and then set badgeValue from that method

Upvotes: 2

Related Questions