In this question I was looking for a way to ensure that a variable is of a certain type using a define. But sometimes I have this situation:
- (void) theSitu
Hmm... Interesting question. I have a few things that should work (theoratically).
You can get the function name that is being executed using __func__
. (See this).
You can get the Selector from a string:
SEL selector = selectorFromString(@"doWork");
You can get Method object of an instance of a class using objective C runtime.
Method *m = class_getInstanceMethod(self, selector);
You can get number of arguments of a method from:
method_getNumberOfArguments
you can get argument type using
method_copyArgumentType
And from here you should be able to assert.
I know, long shot - I have not tried to run the code. I'll update the answer if I get on a Mac soon.