Class:
定义在 objc.h
:
/// An opaque type that represents an Objective-C class.
typedef struct objc_class *Class;
objc_class
定义在runtime.h
:
Class _Nonnull isa OBJC_ISA_AVAILABILITY;
#if !__OBJC2__
Class _Nullable super_class OBJC2_UNAVAILABLE;
const char * _Nonnull name OBJC2_UNAVAILABLE;
long version OBJC2_UNAVAILABLE;
long info OBJC2_UNAVAILABLE;
long instance_size OBJC2_UNAVAILABLE;
struct objc_ivar_list * _Nullable ivars OBJC2_UNAVAILABLE;
struct objc_method_list * _Nullable * _Nullable methodLists OBJC2_UNAVAILABLE;
struct objc_cache * _Nonnull cache OBJC2_UNAVAILABLE;
struct objc_protocol_list * _Nullable protocols OBJC2_UNAVAILABLE;
#endif
} OBJC2_UNAVAILABLE;
Method
Method
定义在 runtime.h
:
struct objc_method {
SEL _Nonnull method_name OBJC2_UNAVAILABLE;
char * _Nullable method_types OBJC2_UNAVAILABLE;
IMP _Nonnull method_imp OBJC2_UNAVAILABLE;
} OBJC2_UNAVAILABLE;
Method方法包括了 SEL 也就是方法名称,types,标示方法的参数类型,IMP标示该方法具体实现的函数指针
SEL
SEL
定义在objc.h
:
typedef struct objc_selector *SEL;
表示的方法的签名
IMP
IMP
定义在 objc.h
typedef void (*IMP)(void /* id, SEL, ... */ );
id
:
/// A pointer to an instance of a class.
typedef struct objc_object *id;
/// Represents an instance of a class.
struct objc_object {
Class _Nonnull isa OBJC_ISA_AVAILABILITY;
};
id 是一个指向 objc_object的结构体指针,objc_object里只有一个 isa
网友评论