Issue
I started taking a look of the new Swift
on Xcode 6
, and I tried some demo projects and tutorials. Now I am stuck at:
Instantiating and then presenting a viewController
from a specific storyboard
Objective-C Solution
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"myStoryboardName" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"myVCID"];
[self presentViewController:vc animated:YES completion:nil];
How to achieve this on Swift?
I know it's an old thread, but I think the current solution (using hardcoded string identifier for given view controller) is very prone to errors.
I've created a build time script (which you can access here), which will create a compiler safe way for accessing and instantiating view controllers from all storyboard within the given project.
For example, view controller named vc1 in Main.storyboard will be instantiated like so:
If you have a Viewcontroller not using any storyboard/Xib, you can push to this particular VC like below call :