My NSArray holds two different types of classes, both of which derive from NSObject and have a method with the same name. If I call:
[myArrayList
makeObjectsPerformSelector:@selector(dehydrate)
withObject:myParamObjec];
I get the 'unrecognized selector' exception:
uncaught exception 'NSInvalidArgumentException', reason: '*** -[BlankItem dehydrate]: unrecognized selector sent to instance 0x10328e0'
If I iterate through each element of 'myArrayList' and manually invoke 'hydrate' on BlankItem as a selector, same thing but if I cast correctly, everything is okay.
for (id item in myArray)
{
if ([item isKindOfClass:[BlankItem class]])
{
BlankItem *blankItem = (BlankItem *)item;
// this works
[blankItem dehydrate:connectionFactory];
// this produces the exception
[item performSelector:@selector(dehydrate) withObject:myParamObjec];
}
else
{
[item performSelector:@selector(dehydrate) withObject:myParamObjec];
}
}
Class declarations:
@interface BlankItem : NSObject {
}
- (void)hydrate:(MyParamClass *)paramClass;
@end
@interface RegularItem : NSObject {
}
- (void)hydrate:(MyParamClass *)paramClass;
@end
Do the two classes, BlankItem and RegularItem need to inherit from a common BaseClass in order for this to be correct?
I don't see what I'm doing or not doing that's producing this error. Any suggestions?