Grimless
Grimless

Reputation: 1266

Finding out if a class is a subclass of another class (Objective-C)

So I have a Class object, say for class 'D'. Is there a way to figure out if that class object is a subclass of another Class object, say 'B'? I tried -isKindOfClass: and isMemberOfClass, but neither worked. Thanks!

Upvotes: 3

Views: 358

Answers (2)

MarrLiss
MarrLiss

Reputation: 808

You should use class method +isSubclassOfClass.

Upvotes: 2

Jacob Relkin
Jacob Relkin

Reputation: 163228

Well hello there Grimless!

-isKindOfClass: should work fine, it says so in the documentation: http://developer.apple.com/library/mac/#/library/ios/documentation/Cocoa/Reference/Foundation/Protocols/NSObject_Protocol/Reference/NSObject.html

But there is another class method in NSObject called +isSubclassOfClass: that you should use instead.

Upvotes: 1

Related Questions