Created
March 3, 2016 10:54
-
-
Save balazsnemeth/18e703479029d43cffb0 to your computer and use it in GitHub Desktop.
Default protocol implementation to load any view from NIB
This file contains hidden or 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
protocol LoadableView { | |
static func loadViewFromNibName(nibName: String) -> Self | |
} | |
extension LoadableView { | |
/** | |
Default protocol implementation to load a view from nib! | |
*/ | |
static func loadViewFromNibName(nibName: String) -> Self { | |
let nibViews = NSBundle.mainBundle().loadNibNamed(nibName, owner: nil, options:nil) | |
let view = nibViews[0] as! Self | |
return view | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment