I often claim that the object "isKindOfClass" of some class in Objective-C. I do it like this:
NSAssert([obj isKindOfClass:[AClass class]], @"%@ should be kind of class %@", obj, [[AClass class] description]);
I am wondering what is the best way to make a short cut. I am thinking of a macro definition, something like:
#define NSClassAssert(obj, class) NSAssert([obj isKindOfClass:class], @"%@ should be of class %@", obj, [class description])
I am worried that this may cause some unpleasant compilation errors or run-time problems, is there something fundamentally wrong in this regard, is there an easy way to do this?
source
share