iOS反射机制
来源:互联网 发布:php调用python 编辑:程序博客网 时间:2024/05/19 12:17
/**
*获取对象的所有属性
*/
- (NSArray *)getAllPropertis {
NSMutableArray *array = [NSMutableArrayarray];
unsigned int count;
objc_property_t *properties = class_copyPropertyList(self, &count); //获取属性列表
for (long i = 0; i < count; i++) {
objc_property_t property = properties[i];
NSString *propertyName = [NSStringstringWithCString:property_getName(property)encoding:NSUTF8StringEncoding]; //将属性转化为NSString类型
[array addObject:propertyName];
}
return array;
}
/**
*获取对象的所有方法
*/
-(NSArray*)getAllMethodList
{
unsigned int methodCount =0;
Method* methodList = class_copyMethodList([selfclass],&methodCount);
NSMutableArray* array = [NSMutableArrayarrayWithCapacity:methodCount];
for(int i = 0; i<methodCount; i++)
{
Method tempMethod = methodList[i];
IMP imp = method_getImplementation(tempMethod);//函数指针
SEL name = method_getName(tempMethod);//选择子
const char* cName =sel_getName(method_getName(tempMethod));
int argumentsCount = method_getNumberOfArguments(tempMethod); //方法的参数个数
const char* encoding =method_getTypeEncoding(tempMethod); //编码方式
NSString* strName = [NSStringstringWithUTF8String:cName];
[array addObject:strName];
}
free(methodList);
return array;
}
- iOS反射机制
- iOS实现反射机制
- iOS实现反射机制
- iOS反射机制
- IOS 反射机制
- iOS反射机制
- iOS反射机制
- iOS反射机制
- iOS反射机制--1.属性反射
- ios中的动态反射机制
- iOS反射机制: objc_property_t的使用
- iOS反射机制: objc_property_t的使用
- IOS反射机制的几个重要函数
- iOS反射机制: objc_property_t的使用
- iOS开发—巧用反射机制
- iOS开发:Object-C的反射机制
- iOS 开发--Objective-C 反射机制
- [iOS]Swift-反射机制及KVC
- java入门-成员变量的隐藏与方法重写(super)
- 心情日记
- selector的使用
- Introduction to guided filter
- 第九周项目三 输出星号图(1)
- iOS反射机制
- INTJ之ENTJ
- 易飞90设计自定义画面新增功能说明
- 算法与数据结构(五)--希尔排序
- 华为荣耀四核官方各版本大集合,速来下载哦!(不定期更新)
- 数挖开源,好像挺不错,未试过
- mac 不能识别android 手机办法
- Leetcode--Minimum Depth of Binary Tree
- tomcat unable to start within 45 seconds