Created
June 6, 2013 14:55
-
-
Save markd2/5722116 to your computer and use it in GitHub Desktop.
Jump through an IMP
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
| #import <Foundation/Foundation.h> | |
| // Call a method through a cached IMP pointer. | |
| // clang -g -Wall -framework Foundation -o imp imp.m | |
| int main (void) { | |
| @autoreleasepool { | |
| NSString *string = @"Bork"; | |
| IMP uppercase = [string methodForSelector: @selector(uppercaseString)]; | |
| NSString *upcase = uppercase (string, @selector(flonknozzle)); | |
| NSLog (@"%@ -> %@", string, upcase); | |
| } | |
| return 0; | |
| } // main |
#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
NSString *upcase = uppercase (string, @selector(flonknozzle));
this line was wrong in my xcode cmd projiect..