Objective

delims 于 2020-08-13 发布

几个方法。

NSObject

// hash和地址一样,占用空间8字节。原因应该是只有一个isa指针。

NSObject *object = NSObject.new;
NSLog(@"%lx",(unsigned long)object.hash);
NSLog(@"%p",object);
NSLog(@"%lu",sizeof(object));

isa 和 meta class

struct method_t {
    SEL name;
    const char *types;
    MethodListIMP imp;
	
    struct SortBySELAddress :
        public std::binary_function<const method_t&,
                                    const method_t&, bool>
    {
        bool operator() (const method_t& lhs,
                         const method_t& rhs)
        { return lhs.name < rhs.name; }
    };
};