转载

类的本质

2016-08-18  本文已影响11人  一块豆腐

类的本质


1.类的本质


2.如何获取类对象

格式:[实例对象   class ];
如:   [dog class];
格式:[类名 class];
如:[Dog class]

3.类对象的用法

[Dog test];

Class c = [Dog class];
[c test];
Dog *g = [Dog new];

Class c = [Dog class];
Dog *g1 = [c new];

5.OC实例对象 类对象 元对象之间关系

NSObject.h
@interface NSObject <NSObject> {
    Class isa  OBJC_ISA_AVAILABILITY;
}
objc.h
/// An opaque type that represents an Objective-C class.
typedef struct objc_class *Class;

/// Represents an instance of a class.
struct objc_object {
    Class isa  OBJC_ISA_AVAILABILITY;
};
runtime.h
struct objc_class {
    Class isa  OBJC_ISA_AVAILABILITY;

#if !__OBJC2__
    Class super_class                                        OBJC2_UNAVAILABLE;
    const char *name                                         OBJC2_UNAVAILABLE;
    long version                                             OBJC2_UNAVAILABLE;
    long info                                                OBJC2_UNAVAILABLE;
    long instance_size                                       OBJC2_UNAVAILABLE;
    struct objc_ivar_list *ivars                             OBJC2_UNAVAILABLE;
    struct objc_method_list **methodLists                    OBJC2_UNAVAILABLE;
    struct objc_cache *cache                                 OBJC2_UNAVAILABLE;
    struct objc_protocol_list *protocols                     OBJC2_UNAVAILABLE;
#endif

} OBJC2_UNAVAILABLE;
关系图.png
上一篇下一篇

猜你喜欢

热点阅读