Created
March 15, 2019 15:39
-
-
Save joshuajhomann/40a76b4f84504be0ff8f854ba15cef0a to your computer and use it in GitHub Desktop.
firstParent
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 UIResponder { | |
func firstParent<T: UIResponder>(ofType type: T.Type ) -> T? { | |
return next as? T ?? next.flatMap { $0.firstParent(ofType: type) } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment