Last active
November 15, 2017 00:32
-
-
Save efremidze/faca8f8363260f0ec72123c48ac868c3 to your computer and use it in GitHub Desktop.
This file contains 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
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