class objc_getClass object_getclass - ShenYj/ShenYj.github.io GitHub Wiki
-
class
/// 类方法返回的就是自己 + (Class)class { return self; } /// self为对象,结果是类对象 /// 非编译器优化方法 - (Class)class { return object_getClass(self); }
-
objc_getClass
/*********************************************************************** * objc_getClass. Return the id of the named class. If the class does * not exist, call _objc_classLoader and then objc_classHandler, either of * which may create a new class. * Warning: doesn't work if aClassName is the name of a posed-for class's isa! **********************************************************************/ Class objc_getClass(const char *aClassName) { if (!aClassName) return Nil; // NO unconnected, YES class handler return look_up_class(aClassName, NO, YES); }
-
object_getclass
/*********************************************************************** * object_getClass. * Locking: None. If you add locking, tell gdb (rdar://7516456). **********************************************************************/ Class object_getClass(id obj) { if (obj) return obj->getIsa(); else return Nil; }
class | object_getclass | objc_getClass | |
---|---|---|---|
传入参数 | - | id类型 | 类名的字符串 |
操作对象 | obj | 这个id的isa指针所指向的Class | 这个类的类对象 |
实例对象时 | 和object_getclass() 一致 |
和class 一致 |
- |
类对象/元类对象时 | 返回的消息对象本身 | 返回的是下一个对象 | - |