Skip to content

Instantly share code, notes, and snippets.

@hossamghareeb
Created January 3, 2021 12:02
Show Gist options
  • Save hossamghareeb/8288d7653bd43ce212fbb5e14dad68d0 to your computer and use it in GitHub Desktop.
Save hossamghareeb/8288d7653bd43ce212fbb5e14dad68d0 to your computer and use it in GitHub Desktop.
instantiate view controller from storyboard
// Assuming you use one storyboard per view controller
extension UIViewController {
static func fromStoryboard() -> Self {
let name = String(describing: Self.self)
let sb = UIStoryboard(name: name, bundle: nil)
return sb.instantiateViewController(identifier: name) as! Self
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment