Recently, I wrote an application in java (for android) that used reflection to call methods on some objects. The argument number and type were unknown, that is, I had a single mechanism that got the name of the object, the name of the method and an array of parameters (using JSON) and called the specified method on the specified object with an array of arguments (Object [] filled with arguments of the required types).
Now I need to implement the same for iOS, I was able to call the selector when I knew the number of parameters that such a selector expected:
SEL selector = NSSelectorFromString(@"FooWithOneArg");
[view performSelectorInBackground:selector withObject:someArg];
I know that I can get the number of arguments the selector gets using
int numberOfArguments = method_getNumberOfArguments(selector);
But is there a way to make a generic call like this:
[someObject performSelector:selector withObject:arrayOfObjects]
which is pretty much equivalent
someMethod.invoke(someObject, argumentsArray[]);
?
, .
, .