I often find myself asserting that an 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'm wondering about the best way to make a short-cut for it. I'm thinking about defining a macro, something like:
#define NSClassAssert(obj, class) NSAssert([obj isKindOfClass:class], @"%@ should be of class %@", obj, [class description])
I'm worried that this might cause some nasty intractable compile errors or run-time problems, is there anything fundamentally wrong with doing it this way, is there a plain better way to do it?