Skip to content

Instantly share code, notes, and snippets.

@balazsnemeth
Created March 3, 2016 10:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save balazsnemeth/18e703479029d43cffb0 to your computer and use it in GitHub Desktop.
Save balazsnemeth/18e703479029d43cffb0 to your computer and use it in GitHub Desktop.
Default protocol implementation to load any view from NIB
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