I suspect that obj, despite the name, is a class. Example:
Class obj = [NSObject class]; Class cls = object_getClass(obj); Class cls2 = [obj class]; NSLog(@"%p",cls); // 0x7fff75f56840 NSLog(@"%p",cls2); // 0x7fff75f56868
The reason is that the class of the class object is the same class, but the object_getClass class is a meta-class (class of the class). This makes sense because the class is an instance of the metaclass, and according to the documentation object_getClass returns "The object of the class whose instance the object is." The result in LLDB will be:
(lldb) p cls (Class) $0 = NSObject (lldb) p cls2 (Class) $1 = NSObject (lldb) po cls $2 = 0x01273bd4 NSObject (lldb) po cls2 $3 = 0x01273bc0 NSObject
If you replace Class obj = [NSObject class]; on NSObject *obj = [NSObject new]; , the result will be the same when printing cls and cls2. I.e
NSObject *obj = [NSObject new]; Class cls = object_getClass(obj); Class cls2 = [obj class]; NSLog(@"%p",cls);
source share