当前位置: 移动技术网 > 移动技术>移动开发>IOS > iOS----------Runtime 获取属性列表 方法列表

iOS----------Runtime 获取属性列表 方法列表

2019年04月09日  | 移动技术网移动技术  | 我要评论

导入

#import <objc/runtime.h>

 

unsigned int count;
method *methods = class_copymethodlist([uialertaction class], &count);
for (int i = 0; i < count; i++) {
method method = methods[i];
sel selector = method_getname(method);
nsstring *name = nsstringfromselector(selector);
nslog(@"method_getname:%@",name);
}



    unsigned int numivars;

    ivar *vars = class_copyivarlist([uialertaction class], &numivars);

    nsstring *key=nil;

    for(int i = 0; i < numivars; i++) {

        

        ivar thisivar = vars[i];

        key = [nsstring stringwithutf8string:ivar_getname(thisivar)];

        nslog(@"variable_name :%@", key);

    }

    free(vars);

 

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网