instantiateViewControllerWithIdentifier and pass data
ios, segue, storyboard
Solution
If you instantiate a navigationController, you can use the `viewControllers` property to get the inner viewController of the navigation controller.
Something like this:
UINavigationController *navigationController = [self.storyboard instantiateViewControllerWithIdentifier:identifier];
MBFancyViewController *viewController = navigationController.viewControllers[0];
// setup "inner" view controller
viewController.foo = bar;
[self presentViewController:navigationController animated:YES completion:nil];
Problem
I am using `Storyboard` in my app and I want to pass data from one view to another view. Instead of using segues I am using `instantiateViewControllerWithIdentifier`. In this case I am instantiate from my first `TableViewController` to a `NavigationController` which has a second `TableViewController` attached because I need the navigation in the second `TableViewController`. Now I want to pass data from my first `TableviewController`, depending which row was clicked, to my second `TableviewController`. In this case `newTopViewController` would be my `NavigationController` but my problem is now how to pass data from `firstTableViewController` to the `secondTableviewController`. ``` - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSString *identifier = [NSString stringWithFormat:@"%@Top", [menuArray objectAtIndex:indexPath.row]]; UIViewController *newTopViewController = [self.storyboard instantiateViewControllerWithIdentifier:identifier]; } ```