Skip to content

Instantly share code, notes, and snippets.

@leojkwan leojkwan/HasNib.swift
Last active Jul 16, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.