Skip to content

Instantly share code, notes, and snippets.

@efremidze
Last active November 15, 2017 00:32
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 efremidze/faca8f8363260f0ec72123c48ac868c3 to your computer and use it in GitHub Desktop.
Save efremidze/faca8f8363260f0ec72123c48ac868c3 to your computer and use it in GitHub Desktop.
extension UIView {
func toType<T: UIView>(of type: T.Type) -> T {
guard let value = self as? T else {
fatalError("Cannot convert value of type `\(type(of: self))` to expected type `\(type)`")
}
return value
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment