Skip to content

Instantly share code, notes, and snippets.

@mikeash
Created July 27, 2016 15:15
Show Gist options
  • Save mikeash/66b322ef10579b5ac7505ccc68fca44a to your computer and use it in GitHub Desktop.
Save mikeash/66b322ef10579b5ac7505ccc68fca44a to your computer and use it in GitHub Desktop.
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