-
-
Save karajanyp/96d9c7e511d52d4db73473201ae7fe12 to your computer and use it in GitHub Desktop.
Jump through an IMP
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
#import <Foundation/Foundation.h> | |
// Call a method through a cached IMP pointer. | |
// clang -g -Wall -framework Foundation -o imp imp.m | |
id (*uppercase)(id, SEL, ...); | |
int main (void) { | |
@autoreleasepool { | |
NSString *string = @"Bork"; | |
uppercase = [string methodForSelector: @selector(uppercaseString)]; | |
NSString *upcase = uppercase (string, @selector(flonknozzle)); | |
NSLog (@"%@ -> %@", string, upcase); | |
} | |
return 0; | |
} // main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment