Skip to content

Instantly share code, notes, and snippets.

@yusuke024
Created April 17, 2015 11:27
Show Gist options
  • Select an option

  • Save yusuke024/42b0ac48a88c313cd304 to your computer and use it in GitHub Desktop.

Select an option

Save yusuke024/42b0ac48a88c313cd304 to your computer and use it in GitHub Desktop.
@import ObjectiveC;
@interface MyClass : NSObject
@end
@implementation MyClass
+ (void)methodA {
Method mb = class_getClassMethod([self class], @selector(methodB:));
BOOL (* action)(id, Method, NSNumber *) = (BOOL (*)(id, Method, NSNumber *))method_invoke;
BOOL returnValue = action([self class], mb, [NSNumber numberWithBool:YES]);
method_getNumberOfArguments(mb); // number of args
method_getArgumentType(mb, 2, dst, 256); // arg type
}
+ (BOOL)methodB:(NSNumber *)a {
return [a boolValue];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment