Created
April 27, 2016 18:01
-
-
Save sandofsky/0a8b5977afb16af1c6083fe97f0ac867 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 | |
protocol StoryboardBacked:class { | |
static func newFromStoryboardWithName(name:String?, bundle:NSBundle?) -> Self | |
} | |
extension StoryboardBacked { | |
static func newFromStoryboardWithName(name:String?, bundle:NSBundle?) -> Self { | |
let realName = name ?? NSStringFromClass(self as AnyClass).componentsSeparatedByString(".").last! | |
let storyboard = UIStoryboard(name: realName, bundle: bundle) | |
let controller = storyboard.instantiateInitialViewController()! as! Self | |
return controller | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment