If you want to create a new UIViewController, you have two ways to do this.
1st path (programmatic path): create a new class that is a subclass of UIViewController. Thus, you create an instance of the view controller using the following code:
var viewController = ViewControl()
2nd way (xib / storyboard path): Create a new viewController using xib or storyboard. So, if you chose this method and you have a view controller created in xib or a storyboard, you must create a new view controller link using the following code:
//Xib var viewController = UIViewController(nibName: "ViewController", bundle: nil) //Storyboard var viewControllerStoryboardId = "ViewController" var storyboardName = "Main" var storyboard = UIStoryboard(name: storyboardName, bundle: NSBundle.mainBundle()) let viewController = storyboard.instantiateViewControllerWithIdentifier(viewControllerStoryboardId) as UIViewController!
source share