Skip to content

Instantly share code, notes, and snippets.

@HHuckebein
Created February 8, 2016 07:46
Show Gist options
  • Save HHuckebein/fd9265bd59efea473bb4 to your computer and use it in GitHub Desktop.
Save HHuckebein/fd9265bd59efea473bb4 to your computer and use it in GitHub Desktop.
UIStoryboard extension to load a storyboard by means of a StoryboardRepresentable type
extension UIStoryboard {
class func storyboard(storyboard: StoryboardRepresentable, bundle: NSBundle? = nil) -> UIStoryboard {
return UIStoryboard(name: storyboard.storyboardName, bundle: bundle)
}
}
protocol StoryboardRepresentable {
var storyboardName: String { get }
}
extension StoryboardRepresentable where Self: RawRepresentable, Self.RawValue == String {
var storyboardName: String {
return self.rawValue
}
}
enum ModulAStoryboardEnum: String, StoryboardRepresentable {
case StoryboardA
case StoryboardB
case StoryboardC
}
enum ModulBStoryboardEnum: String, StoryboardRepresentable {
case StoryboardA
case StoryboardB
case StoryboardC
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment