How to tell if a Class inherits from NSObject (Objective-C)
I'm working in Objective-C on the iPhone and need to know whether a 'Class' inherits from 'NSObject'. I tried checking if it responds to an NSObject selector: bool success = [myClass respondsToSelector:@selector(class)]; but you can guess what happened... it didn't even respond to "respondsToSelector:" so it throws a "does not implement doesNotRecognizeSelector:" exception. I tried to catch that exception, but it looks like it can't be caught with a @try-@catch. Any ideas? Go direct to the Objective-C runtime: #import <objc/runtime.h> /* originally posted version — works because eventually