设为首页 加入收藏

TOP

iOS----------Runtime 获取属性列表 方法列表
2019-08-26 07:04:52 】 浏览:24
Tags:iOS----------Runtime 获取 属性 方法

导入

#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);

 

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇iOS-UIImage图片绘制颜色 下一篇现有工程中集成Cordova

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目