Last active
July 16, 2018 21:07
-
-
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.
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
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