I have this line of code:
[UIStoryboard storyboardWithName:(NSString *) bundle (NSBundle *)];
and a storyboard file. Where do I actually insert the name of the controller, and where do I find the bundle?
It is a stupid question, but I can't figure it out
Everything is really straightforward!
This is the code:
UIStoryboard *storyboard =
[UIStoryboard storyboardWithName:@"MainStoryboard"
bundle:[NSBundle mainBundle]];
Where is @"Main Storyboard" is the name of your .storyboard file. Bundle is just the bundle that contains your .storyboard file, usually is the main bundle of your app.
If you want to get access to some of the UIViewControllers, for example, with the purpose of pushing it to the stack of your UINavigationController, then you must do this:
UIViewController *yourViewController =
[storyboard instantiateViewControllerWithIdentifier:@"viewControllerIdentifier"];
You can set Identifier to your UIViewController in the Xcode's Identity Inspector!
Hope it helps you!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With