Using the Objective-C runtime library, how do we find out if an object is a class object rather than an instance of a class?
Asked
Active
Viewed 134 times
6
-
what is the difference between what you mean by "an object that is a class" and an instance of a class? – Jake Smith Apr 09 '13 at 18:46
-
1@Boon: I'm having trouble imagining when this would be important. In any case where it is important, you should already know which you're expecting. In cases where you don't know, then all you usually need to care about is whether the object quacks like a duck. If it is important and you don't know, then that sounds like a design problem for which discovering the answer is just a band-aid. I do agree it's a legitimate question, though. – Chuck Apr 09 '13 at 18:57
1 Answers
5
Easiest surefire way I know is class_isMetaClass(object_getClass(yourObject))
. (This works because classes are always instances of metaclasses.)

Chuck
- 234,037
- 30
- 302
- 389