Created
January 3, 2021 12:02
-
-
Save hossamghareeb/8288d7653bd43ce212fbb5e14dad68d0 to your computer and use it in GitHub Desktop.
instantiate view controller from storyboard
This file contains hidden or 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
// 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