Skip to content

Instantly share code, notes, and snippets.

@joshuajhomann
Created March 15, 2019 15:39
Show Gist options
  • Save joshuajhomann/40a76b4f84504be0ff8f854ba15cef0a to your computer and use it in GitHub Desktop.
Save joshuajhomann/40a76b4f84504be0ff8f854ba15cef0a to your computer and use it in GitHub Desktop.
firstParent
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