Skip to content

Instantly share code, notes, and snippets.

@lightsprint09
Created March 22, 2016 15:11
Show Gist options
  • Save lightsprint09/98ad270123bc81a29c49 to your computer and use it in GitHub Desktop.
Save lightsprint09/98ad270123bc81a29c49 to your computer and use it in GitHub Desktop.
//
// 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