I have a slightly odd situation.
Here's a simplified example:
- (void) someMethod: (Class) class someArg: (id) arg
{
[class performClassMethodWithArg: arg];
}
Unsurprisingly, the compiler complains that
"warning: no '+performClassMethodWithArg:' method found".
Is there some way to type that parameter as "a class that supports
this class method"? If it were an object, I could use a protocol.
Is there an equivalent for classes?
Although I'd rather not be restricted to a specific class
hierarchy, I did try
- (void) someMethod: (MyClass) class someArg: (id) arg
but the compiler complained that
"error: can not use an object as parameter to a method"
Any suggestions?
As to why? performClassMethodWithArg is actually a constructor
that creates a new object of type 'class' using 'arg' as input.
It's in the middle of a loop (ie input is an array of arg of
varying type but conforming to a particular protocol) that
normalises and extends 'arg'. While the specific types of 'class'
and 'arg' vary I want to perform the same operation on them.
--
Andrew White