tags:

views:

29

answers:

1

I want to fetch information about the types of the arguments in an instance-method at runtime.

For instance if I have the method:

- (void)doSomethingWithItem:(Item *)item usingName:(id<Type2>)name;

Here I would like to retrieve Item and id<Type2>.

Is there any way of doing this, or is there no type information available for the arguments at runtime?

+1  A: 

There is "runtime" method argument type information, which is basically the NSMethodSignature class all about. However, all Objective-C types i.e. Item* and id<Type2> will be conflated to id when compiling, i.e. you can't distinguish between different id subtypes.

KennyTM
... as well you can't distinguish between certain other types, either. The @encode goop in Objective-C is woefully broken.
bbum