您的位置:首页 > 移动开发 > IOS开发

iOS 开发:运行时,查看对象的成员属性

2016-10-28 00:00 483 查看
//运行时,看有哪些成员变量

unsigned int count ;

Ivar *ivarList = class_copyIvarList([UIRefreshControl class], &count);

for (int i = 0; i<count; i++) {//便利所有的成员属性

Ivar ivar = ivarList[i];

NSLog(@"%s",ivar_getName(ivar));

}

free(ivarList);

注意:要导入头文件:#import <objc/message.h>

打印的结果

2016-10-28 11:00:17.862582 test[5765:941929] _style

2016-10-28 11:00:17.862614 test[5765:941929] _contentView

2016-10-28 11:00:17.862622 test[5765:941929] _scrollView

2016-10-28 11:00:17.862628 test[5765:941929] _refreshControlHeight

2016-10-28 11:00:17.862635 test[5765:941929] _visibleHeight

2016-10-28 11:00:17.862641 test[5765:941929] _snappingHeight

2016-10-28 11:00:17.862647 test[5765:941929] _additionalTopInset

2016-10-28 11:00:17.862656 test[5765:941929] _insetsApplied

2016-10-28 11:00:17.862662 test[5765:941929] _adjustingInsets

2016-10-28 11:00:17.862668 test[5765:941929] _automaticContentOffsetAdjustmentEnabledWhenLastIdle

2016-10-28 11:00:17.862674 test[5765:941929] _automaticContentOffsetAdjustmentEnabledNeedsReset

2016-10-28 11:00:17.862680 test[5765:941929] _appliedInsets

2016-10-28 11:00:17.862686 test[5765:941929] _refreshControlState
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  运行时 成员属性
相关文章推荐