My app contains a Tab Bar Controller at the root which has to three tabs - each of which are View Controllers embedded in their own Navigation Controllers. Like this: Tab Controller -> Nav Controller -> View Controller. I'm trying to set a property of the second tab's view controller from the first tab like this (as I would when preparing for segue)
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
if (tabBarController.selectedIndex == 1) {
((CreateViewController *)viewController).myProperty = YES;
}
The method is being called as expected, but as soon as I attempt to set the property the app crashes and I receive the error:
-[UINavigationController setAppearedFromTabBar:]: unrecognized selector sent to instance 0x7fc913d5f510
I have a feeling this has to do with the fact that the View Controller (CreateViewController *) is embedded in a Nav Controller. Do I need to pass the info to the Nav Controller which in turn will pass it to the View Controller? Any help would be appreciated!
(CreateViewController *)[(UINavigationController *)viewController topViewController].myProperty = YES;
– kedzia((CreateViewController *)[(UINavigationController *)viewController topViewController]).myProperty = YES;
– Dana