#import <objc/runtime.h>

@implementation NSObject (PropertyListing)

/* 获取对象的全部属性 */

- (NSDictionary *)properties_aps

{

NSMutableDictionary *props = [NSMutableDictionary dictionary];

unsigned int outCount, i;

objc_property_t *properties = class_copyPropertyList([self class], &outCount);

; i<outCount; i++)

{

objc_property_t property = properties[i];

const char* char_f =property_getName(property);

NSString *propertyName = [NSString stringWithUTF8String:char_f];

id propertyValue = [self valueForKey:(NSString *)propertyName];

if (propertyValue) [props setObject:propertyValue forKey:propertyName];

}

free(properties);

return props;

}

/* 获取对象的全部方法 */

-(void)printMothList

{

;

Method* mothList_f = class_copyMethodList([self class],&mothCout_f);

;i<mothCout_f;i++)

{

Method temp_f = mothList_f[i];

IMP imp_f = method_getImplementation(temp_f);

SEL name_f = method_getName(temp_f);

const char* name_s =sel_getName(method_getName(temp_f));

int arguments = method_getNumberOfArguments(temp_f);

const char* encoding =method_getTypeEncoding(temp_f);

NSLog(@"方法名:%@,參数个数:%d,编码方式:%@",[NSString stringWithUTF8String:name_s],

arguments,

[NSString stringWithUTF8String:encoding]);

}

free(mothList_f);

}


@end

IOS遍历未知对象属性、函数的更多相关文章

  1. IOS 遍历未知对象的属性和方法

    /* 注意:要先导入ObjectC运行时头文件,以便调用runtime中的方法*/ #import <objc/runtime.h> @implementation NSObject (P ...

  2. js之oop <二> 对象属性

    js中对象属性可以动态添加和删除.删除对象属性用delete关键字. function obj(){ } var oo = new obj(); oo.a = "a"; oo.b ...

  3. python遍历并获取对象属性--dir(),__dict__,getattr,setattr

    一.遍历对象的属性: 1.dir(obj) :返回对象的所以属性名称字符串列表(包括属性和方法). for attr in dir(obj): print(attr) 2.obj.__dict__:返 ...

  4. ES6 之 对象属性的可枚举性和遍历

    1.Object.getOwnPropertyDescriptor() 解释:获取对对象属性的描述对象. let obj = { foo: 123 }; console.log(Object.getO ...

  5. Iterator遍历器 调用Symbol.Iterator属性,遍历器对象。

    Iterator实现原理 创建一个指针对象,指向当前数据结构的起始位置.也就是说,遍历器对象本质上,就是一个指针对象. 第一次调用指针对象的next方法,可以将指针指向数据结构的第一个成员. 第二次调 ...

  6. js 对象属性遍历

    function 对象属性遍历(){ var obj = {x:1,y:2,c:3};for (var name in obj){ alert ( obj[name] )} } function 数组 ...

  7. js for in 获得遍历数组索引和对象属性

    for in 遍历对象属性 获取的是对象的属性名 var person ={ name:"admin", age:"21", address:"sha ...

  8. ES6学习--对象属性的遍历

    ES6一共有5种方法可以遍历对象的属性. (1)for...in for...in循环遍历对象自身的和继承的可枚举属性(不含Symbol属性). (2)Object.keys(obj) Object. ...

  9. ES6之6种遍历对象属性的方法

    ES6之6种遍历对象属性的方法 for ... in 循环遍历对象自身的和继承的可枚举属性(不含Symbol属性). Obejct.keys(obj),返回一个数组,包括对象自身的(不含继承的)所有可 ...

随机推荐

  1. javascript 的bind/apply/call性能

    javascript有两种使用频率非常高的三个内置的功能:bind/apply/call.许多技术是基于高点,这些功能实现.这三个功能被用来改变的功能运行环境.从而达到代码复用的目的. 先来所说bin ...

  2. java单元测试(Junit)

    JUnit是由 Erich Gamma 和 Kent Beck 编写的一个回归测试框架(regression testing framework),供Java开发人员编写单元测试之用. 对不同性质的被 ...

  3. Xamarin.Android 入门实例(4)之实现对 SQLLite 进行添加/修改/删除/查询操作

    1.Main.axml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns: ...

  4. 达到J2EE在后台action控制接待javascript弹出的对话框

    1.后台Action于: request.setAttribute("message", "这项username要么password错误,请重新输入!"); 2 ...

  5. WPF技术触屏上的应用系列(一): 3D 图片(照片)墙、柱面墙(凹面墙或者叫远景墙、凸面墙或者叫近景墙)实现

    原文:WPF技术触屏上的应用系列(一): 3D 图片(照片)墙.柱面墙(凹面墙或者叫远景墙.凸面墙或者叫近景墙)实现 去年某客户单位要做个大屏触屏应用,要对档案资源进行展示之用.客户端是Window7 ...

  6. gerrit git使用

    有关git的參考资料 pro git中文版, 最好的git书籍 http://git-scm.com/book/zh 图解git http://marklodato.github.com/visual ...

  7. IIS URL Rewrite Module防盗链规则配置方法

    IIS版本:IIS 7.5 URL Rewrite组件:IIS URL Rewrite Module(http://www.iis.net/downloads/microsoft/url-rewrit ...

  8. 实现DataGridView行的拖动,即实现行的顺序交换

    参考:http://blog.csdn.net/soarheaven/article/details/3267379 1.界面准备 (1)首先在form中添加一个DataGridView控件,将默认A ...

  9. Andrew Stankevich&#39;s Contest (1)

    Andrew Stankevich's Contest (1) 打一半出门了,回来才补完了...各种大数又不能上java..也是蛋疼无比 A:依据置换循环节非常easy得出要gcd(x, n) = 1 ...

  10. 【网络流量最大流量】poj3281Dining

    /* EK算法版本号,哦,慢.....见下文dinic版本号 ----------------------------------------- 最大的问题是网络流量问题 -------------- ...