Created
July 27, 2016 15:15
-
-
Save mikeash/66b322ef10579b5ac7505ccc68fca44a 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
func responderForType<T>(from: UIResponder) -> T? { | |
var current = from | |
while let next = current.nextResponder() { | |
if let result = next as? T { return result } | |
current = next | |
} | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment