Created
October 19, 2016 03:55
-
-
Save jeamesbone/76dca283964a1f2affd5f28564d899bd to your computer and use it in GitHub Desktop.
Storyboard Dependency Injection - UIStoryboard+Scenes.swift
This file contains 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 { | |
func instantiateViewController<S: Scene>(for scene: S) -> S.ViewController { | |
guard let viewController = instantiateViewController(withIdentifier: scene.identifier) as? S.ViewController | |
else { | |
fatalError("expected view controller with identifier '\(scene.identifier)' to be of type '\(String(describing: S.ViewController.self))'") | |
} | |
scene.configureViewController(viewController) | |
return viewController | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment