I am mixing multiple storyboards alongside NIB files in my iOS6 / iOS6 app.
How does memory management work with multiple storyboards?
- Upon launching a storyboardA, if I return to another nib file / go to another storyboard, does that storyboardA just stay there in the memory?
- Am I able to get an "Array" of the storyboards in the stack the way I'm able to get the array of the views in a navigation controller's stack with UIViewControllers?
- For memory management, can I pop or remove a storyboard from the memory? Do I set it to nil when I go to another storyboard?
reasons why I am using multiple storyboards mixed with nib files:
- I want complex narrative storyboard flows. It doesn't make sense to slam them all into one place.
- Eventually I'll work with many different people and I find the arguments for team work, version control compelling enough to opt for the multiple storyboard route
- I'm mixing NIB files because storyboards do not yet work with complex nib files, many programmatic views, etc.
My Code Snippets
Inside InitialNibFile.m <-- that is launched from the appdelegate.
- (IBAction)newStoryboardBtnPressed:(id)sender {
[self.view removeFromSuperview]; // here I remove this view from the superview to save memory
UIStoryboard *newStoryboard = [UIStoryboard storyboardWithName:@"NewStoryboard" bundle:nil];
UIViewController *initialSettingsVC = [newStoryboard instantiateInitialViewController];
[self presentViewController:initialSettingsVC
animated:YES completion:nil];
}
Here, Inside a UIViewController view that is within a storyboard scene.
- (IBAction)anotherStoryboardBtnPressed:(id)sender {
// I'm inside a storyboard right now. I'm calling another storyboard.
// can i remove this storyboard before i launch the otherone? will keeping 2 or 3 toryboards in memory cause a memory leak?
UIStoryboard *settingsStoryboard = [UIStoryboard storyboardWithName:@"AnotherStoryboard" bundle:nil];
UIViewController *initialSettingsVC = [settingsStoryboard instantiateInitialViewController];
// i'm going to load this view controller modally
// initialSettingsVC.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
[self presentViewController:initialSettingsVC
animated:YES
completion:nil];
}