Created
March 16, 2011 16:59
-
-
Save 0xc010d/872834 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
+ (NSInvocation *)invocationWithTarget:(id)target action:(SEL)selector arguments:(NSArray *)arguments retainArguments:(BOOL)retainArguments { | |
NSMethodSignature *signature = nil; | |
if (isClass(target)) { | |
signature = [target methodSignatureForSelector:selector]; | |
} else { | |
signature = [[target class] instanceMethodSignatureForSelector:selector]; | |
} | |
NSInvocation *invocation = [self invocationWithMethodSignature:signature]; | |
[invocation setTarget:target]; | |
if (retainArguments) { | |
[invocation retainArguments]; | |
} | |
NSInteger index = 2; | |
for (id argument in arguments) { | |
[invocation setArgument:&argument atIndex:index++]; | |
} | |
return invocation; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment