Skip to content

Instantly share code, notes, and snippets.

@ianterrell
Created June 15, 2016 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ianterrell/5aa139ab4b835b85cfee8e0f4430b863 to your computer and use it in GitHub Desktop.
Save ianterrell/5aa139ab4b835b85cfee8e0f4430b863 to your computer and use it in GitHub Desktop.
// This handles most storyboard style injection needs
extension UIViewController {
func injectable<T>() -> T? {
var controller: UIViewController? = self
if let nav = self as? UINavigationController {
controller = nav.viewControllers.first
}
return controller as? T
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment