美文网首页
iOS 运行时获取成员变量与属性的方法

iOS 运行时获取成员变量与属性的方法

作者: 呵呵哈哈嘿嘿 | 来源:发表于2016-09-01 11:20 被阅读116次

iOS runtime中class_copyPropertyList和class_copyIvarList的区别

先定义一个Person,要在另一个类中获取Person类中定义的成员变量与属性

Person类中.h文件

Person类中.m文件

然后在另一个类中获取Person类中定义的成员变量与属性

运用class_copyIvarList获取

输出

运用class_copyPropertyList获取

输出

可以看出:

class_copyPropertyList获得的是由@property修饰过的变量,

class_copyIvarList获得的是@property修饰过的变量以及定义的其他变量

相关文章

网友评论

      本文标题:iOS 运行时获取成员变量与属性的方法

      本文链接:https://www.haomeiwen.com/subject/xsvcettx.html