Open multinerd opened 6 years ago
The code below is based on Reusable and uses the StoryboardNames generated to init VCs
StoryboardNames
Usage: let vc = UIStoryboard(storyboard: .Main)
let vc = UIStoryboard(storyboard: .Main)
Usage: let vc = SearchViewController.instantiateFromStoryboard(name: .Main)
let vc = SearchViewController.instantiateFromStoryboard(name: .Main)
I'm new to ruby or I'd make the PR myself, leaving the idea here if anyone does want to implement it.
The code below is based on Reusable and uses the
StoryboardNames
generated to init VCsStoryboard Methods
```swift extension UIStoryboard { /// Convenience Initializers convenience init(storyboard: StoryboardNames, bundle: Bundle? = nil) { self.init(name: storyboard.rawValue, bundle: bundle) } /// Class Functions public static func storyboard(storyboard: StoryboardNames = .Main, bundle: Bundle? = nil) -> UIStoryboard { return UIStoryboard(name: storyboard.rawValue, bundle: bundle) } /// View Controller Instantiation from Generics func instantiateViewControllerUsage:
let vc = UIStoryboard(storyboard: .Main)
ViewController Methods
```swift extension UIViewController { public static func instantiateFromStoryboard(name storyboard: StoryboardNames = .Main) -> Self { func instantiateFromStoryboardUsage:
let vc = SearchViewController.instantiateFromStoryboard(name: .Main)
I'm new to ruby or I'd make the PR myself, leaving the idea here if anyone does want to implement it.