Last active
August 29, 2015 14:23
-
-
Save hartbit/81ff82025482f3b240d0 to your computer and use it in GitHub Desktop.
This is so weird
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 UIView { | |
var firstResponder: UIView? { | |
if self.isFirstResponder() { | |
return self | |
} | |
for subview in self.subviews { | |
if let fr = subview.firstResponder /*as UIView? -- FIX */ { | |
assert(fr != nil, "THIS SHOULD NOT HAPPEN BUT DOES") | |
return fr | |
} | |
} | |
return nil | |
} | |
func findRirstResponder() -> UIView? { | |
if self.isFirstResponder() { | |
return self | |
} | |
for subview in self.subviews { | |
if let fr = subview.findRirstResponder() { | |
assert(fr != nil, "WORKS FINE") | |
return fr | |
} | |
} | |
return nil | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment