Created
July 19, 2016 05:46
-
-
Save mwrites/0c895deaeaa1a5de0966b77879c478d6 to your computer and use it in GitHub Desktop.
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
extension UIStoryboard { | |
static func main() -> UIStoryboard { | |
return UIStoryboard(name: "Main", bundle: nil) | |
} | |
// assuming that name of the class is the identifier | |
static func controllerOfType<C where C : UIViewController> (type : C.Type) -> C { | |
let name = String(type) | |
let vc = UIStoryboard.main().instantiateViewControllerWithIdentifier(name) | |
let instance = vc as! C | |
return instance | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment