一.实例:
- (void)printClassRelationshipWithObject:(id)objc{
NSLog(@"*********************************************");
NSLog(@"\n实例对象地址 - %p %@",objc,objc);
NSLog(@"\n类对象地址 - %p %@",[objc class],[objc class]);
NSLog(@"\n父类对象地址 - %p %@",[objc superclass],[objc superclass]);
NSLog(@"\n元类对象地址 - %p %@",object_getClass(object_getClass(objc)),object_getClass(object_getClass(objc)));
NSLog(@"\n元类的父类对象地址 - %p %@",[object_getClass(objc) superclass],[object_getClass(objc) superclass]);
NSLog(@"\n根元类对象地址 - %p %@",object_getClass(object_getClass(objc)),object_getClass(object_getClass(objc)));
NSLog(@"\n根元类的父类对象地址 - %p %@",[object_getClass(object_getClass(objc)) superclass],[object_getClass(object_getClass(objc)) superclass]);
NSLog(@"\n根根元类对象地址 - %p %@",object_getClass(object_getClass(object_getClass(objc))),object_getClass(object_getClass(object_getClass(objc))));
NSLog(@"\n根根元类的父类对象地址 - %p %@",[object_getClass(object_getClass(object_getClass(objc))) superclass],[object_getClass(object_getClass(object_getClass(objc))) superclass]);
NSLog(@"*********************************************");
}
7A74DD67B72E20DC4B6DAA4E1784C18D.jpg
二、由实例的结果,我们总结出实例对象-类对象-元类之间的关系:
3554D633-B2DB-47BB-8AE5-BC418D451FD8.png
网友评论