Skip to content

Instantly share code, notes, and snippets.

@sooop
Created May 14, 2013 11:39
Show Gist options
  • Save sooop/5575307 to your computer and use it in GitHub Desktop.
Save sooop/5575307 to your computer and use it in GitHub Desktop.
NSMakeInvocation - Create NSInvocation instance from object, selector and array of arguements.
#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