Created
December 8, 2018 10:05
-
-
Save mehdok/dd1f3c2c068848ab4129a377e1e8ec71 to your computer and use it in GitHub Desktop.
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
import UIKit | |
public protocol StoryboardInitializable { | |
static var storyboardIdentifier: String { get } | |
} | |
public extension StoryboardInitializable where Self: UIViewController { | |
public static var storyboardIdentifier: String { | |
return String(describing: Self.self) | |
} | |
public static func initFromStoryboard(name: String = "Main") -> Self { | |
let storyboard = UIStoryboard(name: name, bundle: Bundle(for: self)) | |
return storyboard.instantiateViewController(withIdentifier: storyboardIdentifier) as! Self | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment