Create a gist now

Instantly share code, notes, and snippets.

@karajanyp /imp.m forked from markd2/imp.m
Created Apr 11, 2018

What would you like to do?
Jump through an IMP
#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