Skip to content

Instantly share code, notes, and snippets.

@hprobotic
Created February 10, 2017 05:01
Show Gist options
  • Save hprobotic/c842f160f127dfbce1f8f3ce67a4a019 to your computer and use it in GitHub Desktop.
Save hprobotic/c842f160f127dfbce1f8f3ce67a4a019 to your computer and use it in GitHub Desktop.
import UIKit
public enum Storyboard: String {
case Activity
case Dashboard
case Home
case Discovery
public func instantiate<VC: UIViewController>(_ viewController: VC.Type,
inBundle bundle: Bundle = .framework) -> VC {
guard
let vc = UIStoryboard(name: self.rawValue, bundle: nil)
.instantiateViewController(withIdentifier: VC.storyboardIdentifier) as? VC
else { fatalError("Couldn't instantiate \(VC.storyboardIdentifier) from \(self.rawValue)") }
return vc
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment