I want get the return value class of an instance in runtime. The thing it's that I have a SEL
type var where I store a selector. I have a variable named id _instance
that points to an instance that I know it performs the selector. Before perform the method I want to know if I have to do:
NSObject* returnValue=[_instance performSelector:_selector withObject:params.params];
or:
[_instance performSelector:_selector withObject:params.params];
I have read a post where someone explain the way to have that with objective-c runtime:
Method m = class_getClassMethod([_instance class], _selector);
char ret[256];
method_getReturnType(m, ret, 256);
NSLog(@"Return type: %s", ret);
But the outputs is nothing like ret is empty.
Really it can be enough to know if it's a void or have a return type but I don't know where to search. I have read the objective-c runtime reference but the only thing I found is the method_getReturnType...
. Any idea?