How to know what two kinds of object is colliding?

In my game there are a lot of kinds of physics objects.Now I add tag for every object class.So in onContactBegin,I need write a very long list to judge what kind of object is contact.getShapeA and contact.getShapeB.
Is there a easy way to do this?

For example in cocos2d-ipone
-(BOOL)ccPhysicsCollisionBegin:(CCPhysicsCollisionPair *)pair ClassA:(CCNode *)nodeA ClassB:(CCNode *)nodeB
So it’s already know nodeA is ClassA and nodeB is ClassB

you can create a base class with physics property and write contact code in classes and not in contact listener.
See this post: