RunTime应用--获取类中所有的私有变量,属性,和方法
来源:互联网 发布:饭店点菜软件 编辑:程序博客网 时间:2024/05/16 08:02
准备数据:
#import "model.h"@interface model()@property (copy, nonatomic) NSString *name;@property (strong, nonatomic) NSMutableDictionary *dic;@property (assign) NSInteger integer;@property (assign) BOOL bol;-(void) createObject;-(void) createObject:(NSDictionary *)dic;@end@implementation model@end调用:
#pragma mark --获取私有方法和属性-(void) getIvarsNameAndType{ unsigned int count = 0; Ivar *ivars = class_copyIvarList([model class], &count); for(int i=0;i<count;i++){ NSString *name = [NSString stringWithUTF8String:ivar_getName(ivars[i])]; NSString *type = [NSString stringWithUTF8String:ivar_getTypeEncoding(ivars[i])]; NSLog(@"变量名:%@\n属性:%@",name,type); }}#pragma mark --获取私有方法-(void)getMethods{ unsigned int count = 0; Method *mets = class_copyMethodList([model class], &count); for(int i=0;i<count;i++){ NSString *str = [NSString stringWithCString:method_getTypeEncoding(mets[i]) encoding:NSUTF8StringEncoding]; SEL sel = method_getName(mets[i]); NSString *name = [NSString stringWithCString:sel_getName(sel) encoding:NSUTF8StringEncoding]; NSLog(@"方法名:%@\n属性:%@",name,str); }}
阅读全文
0 0
- RunTime应用--获取类中所有的私有变量,属性,和方法
- iOS - 通过runtime获取某个类中所有的变量和方法
- runtime 系列-2获取类的所有特征(属性,实例变量,方法)
- iOS运行时runtime获取私有属性和强制更改私有属性,以及获取私有方法
- Runtime获取一个类中所有成员变量的名字和类型
- Runtime的使用4 【获取属性和方法(包括私有)】
- 获取Java类中所有的方法和属性
- Objective-c - 私有属性和私有方法的应用
- Reflect获取私有属性和私有方法
- runtime获取属性列表,修改属性值,添加并修改私有方法的调用
- OC中私有方法和私有变量
- 通过标准的Runtime API(C函数)打印UIKit中UIView的所有变量、属性以及方法
- runtime 获取类的属性,方法,成员变量,以及协议 字典转model 总结
- 通过runtime获取一个类的所有属性
- 浅谈iOS中私有成员变量和属性的选用
- OC基础—类的私有方法和私有变量
- js的私有变量和私有方法
- 通过Runtime获取私有方法
- Linux 日常使用小记
- UITableView --Swift
- 双向链表的插入及删除图解
- C++学习入门笔记II
- 基于语义分析的可视化引擎
- RunTime应用--获取类中所有的私有变量,属性,和方法
- 炒股心得
- Fragment实现类似activity onResume()功能,控制fragment可见与不可见
- Session
- tf.estimator Quickstart解读
- tdy
- java连接数据库出现的Access denied for user 'é??'@'localhost' (using password: YES)问题:
- MyBatis-Spring-TransactionManager
- 谷歌源码中,增加删除应用机制