Created
February 8, 2016 07:46
-
-
Save HHuckebein/fd9265bd59efea473bb4 to your computer and use it in GitHub Desktop.
UIStoryboard extension to load a storyboard by means of a StoryboardRepresentable type
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
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