Created
November 9, 2017 07:49
-
-
Save iAmrSalman/c59747f53c752893bb7b76d6f6e7db0b to your computer and use it in GitHub Desktop.
[viewController from Storyboard] #uiviewcontroller #swift3 #extension
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
extension UIViewController { | |
func viewController(withStoryBoardname storyBoardName : String) -> UIViewController? { | |
let storyboard = UIStoryboard(name: storyBoardName, bundle: .main) | |
let controller = storyboard.instantiateInitialViewController() | |
return controller | |
} | |
func viewController(withStoryBoardname storyBoardName : String , contollerID : String) -> UIViewController? { | |
let storyboard = UIStoryboard(name: storyBoardName, bundle: .main) | |
let controller = storyboard.instantiateViewController(withIdentifier: contollerID) | |
return controller | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment