iphone - How to use NSInvocation to call a class method? -


i've class method not declared in h file, implemented in m file. want call in class, since return value int, can't use selector directly, use nsinvocation.

below i'm doing:

sel selector = ***; nsmethodsignature *signature = [classa methodsignatureforselector:selector]; nsinvocation *invocation = [nsinvocation invocationwithmethodsignature:signature]; invocation.selector = selector; invocation.target = [classa class]; [invocation setargument:(void *)arg atindex:2]; [invocation invoke]; 

the invoke doesn't succeed, why?

when passing arguments, pass address, not value. try following:

[invocation setargument:&arg                 atindex:2]; 

see [nsinvocation setargument:atindex:] in class reference.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -