Last active
August 3, 2021 10:08
-
-
Save n-b/5420684 to your computer and use it in GitHub Desktop.
Chain Responder Debugging Methods
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
@implementation UIView (FirstResponder) | |
- (UIView*) nb_FirstResponder | |
{ | |
if ([self isFirstResponder]){ | |
return self; | |
} | |
for (UIView *subView in self.subviews) | |
{ | |
UIView *firstResponder = [subView nb_FirstResponder]; | |
if (firstResponder != nil) | |
{ | |
return firstResponder; | |
} | |
} | |
return nil; | |
} | |
@end | |
@implementation UIResponder (chain) | |
- (NSArray*) nb_responderChain | |
{ | |
return [@[self] arrayByAddingObjectsFromArray:[self.nextResponder nb_responderChain]]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment