Created
May 14, 2013 11:39
-
-
Save sooop/5575307 to your computer and use it in GitHub Desktop.
NSMakeInvocation - Create NSInvocation instance from object, selector and array of arguements.
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> | |
(NSInvocation*)XSMakeInvocation(id obj, SEL aSelector, NSArray *args); | |
(NSInvocation*)XSMakeInvocation(id obj, SEL aSelector, NSArray *args) | |
{ | |
NSInvocation *anInvocation; | |
NSMethodSignature *sig; | |
NSUInteger i; | |
sig = [obj methodSignatureForSelector:aSelector]; | |
anInvocation = [NSInvocation invocationWithMethodSignature:sig]; | |
[anInvocation setSelector:aSelector]; | |
[anInvocation setTarget:obj]; | |
for(i=0;i<[sig numberOfArguments]-2;i++) { | |
[anInvocation setArgument:&([args objectAtIndex:i]) atIndex:i+2]; | |
} | |
return anInvocation; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment