Guest User

Untitled

a guest
Apr 23rd, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. foo.send("bar")
  2.  
  3. if ([target respondsToSelector:theSelector]) {
  4. NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:
  5. [target methodSignatureForSelector:theSelector]];
  6. [invocation setTarget:target];
  7. [invocation setSelector:theSelector];
  8. // Note: Indexes 0 and 1 correspond to the implicit arguments self and _cmd,
  9. // which are set using setTarget and setSelector.
  10. [invocation setArgument:arg1 atIndex:2];
  11. [invocation setArgument:arg2 atIndex:3];
  12. [invocation setArgument:arg3 atIndex:4];
  13. // ...and so on
  14. [invocation invoke];
  15. [invocation getReturnValue:&retVal]; // Create a local variable to contain the return value.
  16. }
  17.  
  18. if ( [foo respondsToSelector:NSSelectorFromString(@"bar")] ) [foo performSelector:NSSelectorFromString(@"bar")];
Add Comment
Please, Sign In to add comment