Created
April 21, 2010 23:28
-
-
Save madebyjeffrey/374576 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
/* | |
This code present a way to implement textView:doCommandBySelector, as sent by an NSTextView to its delegate, and implement the method as - (BOOL) method: (NSTextView*)aTextView and avoid the need for if statement chaining. | |
*/ | |
- (BOOL)textView:(NSTextView *)aTextView doCommandBySelector:(SEL)aSelector { | |
if ([self respondsToSelector: aSelector]) { | |
BOOL (*method)(id, SEL, NSTextView*); | |
method = (BOOL (*)(id, SEL, NSTextView*))[self methodForSelector: aSelector]; | |
return method(self, aSelector, aTextView); | |
} else { | |
return NO; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment