Skip to content

Instantly share code, notes, and snippets.

@leojkwan
Last active July 16, 2018 21:07
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 leojkwan/72ef0de616f2cd4ad743644b3e361781 to your computer and use it in GitHub Desktop.
Save leojkwan/72ef0de616f2cd4ad743644b3e361781 to your computer and use it in GitHub Desktop.
Initialize custom nib views in a type-safe-er way when .xib and implementation files are named the same.
public protocol HasNib: class {
static var nib: UINib { get }
}
public extension HasNib {
static var nib: UINib {
return UINib(nibName: String(describing: self), bundle: Bundle(for: self))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment