参考: https://www.jianshu.com/p/8ea1e5169d7a 《objc源码解析-ObjectiveC对象结构》
参考:https://blog.csdn.net/u013378438/article/details/80493158 《基本数据结构:objc_object & objc_class》
struct class_rw_t {
// Be warned that Symbolication knows the layout of this structure.
uint32_t flags;
uint32_t version;
const class_ro_t *ro; // 类不可修改的原始核心
// 下面三个array,method,property, protocol,可以被runtime 扩展,如Category
method_array_t methods;
property_array_t properties;
protocol_array_t protocols;
// 和继承相关的东西
Class firstSubclass;
Class nextSiblingClass;
// Class对应的 符号名称
char *demangledName;
// 以下方法省略
...
}
struct class_ro_t {
uint32_t flags;
uint32_t instanceStart;
uint32_t instanceSize;
#ifdef __LP64__
uint32_t reserved;
#endif
const uint8_t * ivarLayout;
const char * name;
method_list_t * baseMethodList;
protocol_list_t * baseProtocols;
const ivar_list_t * ivars;
const uint8_t * weakIvarLayout;
property_list_t *baseProperties;
method_list_t *baseMethods() const {
return baseMethodList;
}
};
网友评论