Created
December 4, 2020 22:24
-
-
Save MojtabaHs/ea4935263be4bd28a193fe879ec5d0eb to your computer and use it in GitHub Desktop.
Finds and returns the next responder with the given condition.
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
extension UIResponder { | |
func nextFirstResponder(where condition: (UIResponder) -> Bool ) -> UIResponder? { | |
guard let next = next else { return nil } | |
if condition(next) { return next } | |
else { return next.nextFirstResponder(where: condition) } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment