I’m maybe trying to do something wrong, but it would help to make my code simple.
I have some class, to have the same function.
To avoid a long if, else if with isKindOfClass, I want to do something like that :
[(([myClassVar class] *) myClassVar) myFunction];
It can crash if myClassVar doesn’t have myFunction but if I do the if, else if method, it would just not crash but just write an error in the last else case.
Someone have an idea how to do it ?
Thanks in advance,
Damien
Edit :
Answered by SamFisher, my code would be :
if( [myClassVar respondsToSelector:@selector(myFunction) )
[myClassVar performSelector:@selector(myFunction)];
why don’t u use respondsToSelector: and then performSelector: ?