Created
December 11, 2009 07:46
-
-
Save holtwick/254052 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
/* | |
I wonder if a code analyzer would be able to find such a selector... ;) | |
Kids, don't try that at home! | |
*/ | |
char *translatePrivateSelectorName(char *buffer, char *sel) { | |
int pos = 0; | |
for (int i = 0; i < strlen(sel); i++) { | |
if(sel[i] != '/') { | |
buffer[pos++] = sel[i]; | |
} | |
} | |
buffer[pos] = '\0'; | |
return buffer; | |
} | |
// ... in Obj-C Code: | |
- (void)someMethod { | |
char buffer[256]; | |
SEL mySel = sel_registerName(translatePrivateSelectorName(buffer, "s/o/m/e///M/e/t/h/o/d///W/i/t/h///O/b/j/e/c/t/:")); | |
[self performSelector:mySel withObject:nil]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment