Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- foo.send("bar")
- if ([target respondsToSelector:theSelector]) {
- NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:
- [target methodSignatureForSelector:theSelector]];
- [invocation setTarget:target];
- [invocation setSelector:theSelector];
- // Note: Indexes 0 and 1 correspond to the implicit arguments self and _cmd,
- // which are set using setTarget and setSelector.
- [invocation setArgument:arg1 atIndex:2];
- [invocation setArgument:arg2 atIndex:3];
- [invocation setArgument:arg3 atIndex:4];
- // ...and so on
- [invocation invoke];
- [invocation getReturnValue:&retVal]; // Create a local variable to contain the return value.
- }
- if ( [foo respondsToSelector:NSSelectorFromString(@"bar")] ) [foo performSelector:NSSelectorFromString(@"bar")];
Add Comment
Please, Sign In to add comment