#import <objc/runtime.h>
// 通过运行时来遍历每个属性
unsigned int count;
//class_copyIvarList 获取所有属性数组
Ivar *varList = class_copyIvarList([UITextField class],&count);
for (NSInteger i = 0; i < count; i++) {
Ivar var = varList[i];
//遍历所有属性的名字
NSLog(@"%s",ivar_getName(var));
}
//因为是c语言,所以这里需要释放
free(varList);
原文:http://www.cnblogs.com/TheYouth/p/6528167.html