I have a legacy objective c project that uses a code instantiated navigation controller, that loads other view controllers, no problems. However, due to simplicity I changed one of my tableview controllers to be in a storyboard (inside there is a tablevew with some customs cells - but not important). I load the view controller from the storyboard like this:
UIViewController *searchViewController;
searchViewController = [[UIViewController alloc] init];
searchViewController = [[UIStoryboard storyboardWithName:@"Storyboard1" bundle:nil] instantiateViewControllerWithIdentifier:@"resultViewController"];
[self.navigationController pushViewController:searchViewController animated:YES];
That all works fine.
When the searchViewController is finished doing what it does I pop back to the original view controller with:
[self.navigationController popViewControllerAnimated:YES];
Works great as well.
However, when searchViewController was a traditional NIB/XIB that got pushed onto the navigation controller, I always came back to the same searchViewController whenever the user decided to. With the new (storyboard) approach it seems that a whole new instance that have been created meaning that no results are kept inside. This is of course very irritating if the user decides to go back in and check some other search results.
So why does the two methods differ, I mean technically it should be more or less the same under the hood?