Created
March 22, 2016 15:11
-
-
Save lightsprint09/98ad270123bc81a29c49 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
// | |
// ViewController+Instatiation.swift | |
// CardScore | |
// | |
// Created by Lukas Schmidt on 17.09.15. | |
// Copyright © 2015 Lukas Schmidt. All rights reserved. | |
// License MIT | |
// | |
import UIKit | |
extension UIViewController { | |
func instantiateViewControllerWithIdentifier <T: UIViewController>(indentifier:String, storyBoardName:String = "Main") -> T { | |
let storyboard = UIStoryboard(name: storyBoardName, bundle: nil) | |
guard let viewController = storyboard.instantiateViewControllerWithIdentifier(indentifier) as? T else { | |
fatalError("Wrong ViewController Type") | |
} | |
return viewController | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment