I have a few controllers and used Typhoon to inject an object as a property into these controllers. I used Plist Integration. I found that sometimes the object was not injected into the view controllers as expected.
For example, MainTabBarController is the initial view controller and SplashViewController is some other view controller. I have injected the object as the property in the code. The object is verified to be injected into the MainTabBarController.
At some point, I need to present the SplashViewController from the MainTabBarController as follow:
SplashViewController *vc = [[UIStoryboard storyboardWithName:@"Main"
bundle:[NSBundle mainBundle]]
instantiateViewControllerWithIdentifier:@"SplashNavigationController"];
[self presentViewController:vc
animated:YES
completion:nil];
When I tried accessing the object in SplashViewController, it failed. The property does not contain the object.
After some investigation, I found that the storyboard I obtained by calling [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] was NOT a TyphoonStoryboard, but that of MainTabBarController is a TyphoonStoryboard. I therefore changed it to:
SplashViewController *vc = [self.storyboard
instantiateViewControllerWithIdentifier:@"SplashNavigationController"];
[self presentViewController:vc
animated:YES
completion:nil];
And then the SplashViewController contains the injected object. I would like to confirm if this behaviour is expected and this is the correct approach to handle this kind of problem.
Many thanks!