runtime详细使用,后续继续增加

简介: </pre><pre code_snippet_id="149647" snippet_file_name="blog_20140109_1_9522940" name="code" class="objc" style="word-break: break-all; word-wrap: break-word; line-height: 24px; font-size:
</pre><pre code_snippet_id="149647" snippet_file_name="blog_20140109_1_9522940" name="code" class="objc" style="word-break: break-all; word-wrap: break-word; line-height: 24px; font-size: 14px;"> 获取对象的所有属性和属性内容 
- (NSDictionary *)getAllPropertiesAndVaules
{
    NSMutableDictionary *props = [NSMutableDictionarydictionary];
    unsigned int outCount, i;
    objc_property_t *properties =class_copyPropertyList([selfclass], &outCount);
    for (i = 0; i<outCount; i++)
    {
        objc_property_t property = properties[i];
        const char* char_f =property_getName(property);
        NSString *propertyName = [NSStringstringWithUTF8String:char_f];
        id propertyValue = [selfvalueForKey:(NSString *)propertyName];
        if (propertyValue) [props setObject:propertyValue forKey:propertyName];
    }
    free(properties);
    return props;
}
/* 获取对象的所有属性 */
- (NSArray *)getAllProperties
{
    u_int count;
    
    objc_property_t *properties  =class_copyPropertyList([selfclass], &count);
    
    NSMutableArray *propertiesArray = [NSMutableArrayarrayWithCapacity:count];
    
    for (int i = 0; i < count ; i++)
    {
        const char* propertyName =property_getName(properties[i]);
        [propertiesArray addObject: [NSString stringWithUTF8String: propertyName]];
    }
    
    free(properties);
    
    return propertiesArray;
}
/* 获取对象的所有方法 */
-(void)getAllMethods
{
    unsigned int mothCout_f =0;
    Method* mothList_f = class_copyMethodList([selfclass],&mothCout_f);
    for(int i=0;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,编码方式:%@",[NSStringstringWithUTF8String:name_s],
              arguments,
              [NSString stringWithUTF8String:encoding]);
    }
    free(mothList_f);
}

目录
相关文章
|
6月前
|
前端开发 测试技术
【前端验证】记录将发包量作为传参以加速debug的环境优化记录
【前端验证】记录将发包量作为传参以加速debug的环境优化记录
|
9月前
|
缓存 小程序 API
小程序:浅谈小程序更新机制,发版后多久能全覆盖
小程序:浅谈小程序更新机制,发版后多久能全覆盖
246 0
|
10月前
|
JavaScript 开发者
Vite 在运行过程中是如何发现新增依赖的?
Vite 在运行过程中是如何发现新增依赖的?
180 0
|
存储 Java 编译器
JVM特点,基础结构与执行周期
虚拟机(Virtual Machine)指通过软件模拟的具有完整硬件系统功能的、运行在一个完全隔离环境中的完整计算机系统。
157 0
JVM特点,基础结构与执行周期
|
分布式计算 Spark
SPARK最新特性Runtime Filtering(运行时过滤)以及与动态分区裁剪的区别
SPARK最新特性Runtime Filtering(运行时过滤)以及与动态分区裁剪的区别
467 0
SPARK最新特性Runtime Filtering(运行时过滤)以及与动态分区裁剪的区别
|
Android开发
【Android 安装包优化】移除无用资源 ( 自动移除无用资源 | 直接引用资源 | 动态获取资源 id | Lint 检查资源 )(二)
【Android 安装包优化】移除无用资源 ( 自动移除无用资源 | 直接引用资源 | 动态获取资源 id | Lint 检查资源 )(二)
323 0
【Android 安装包优化】移除无用资源 ( 自动移除无用资源 | 直接引用资源 | 动态获取资源 id | Lint 检查资源 )(二)
|
Android开发
【Android 安装包优化】移除无用资源 ( 自动移除无用资源 | 直接引用资源 | 动态获取资源 id | Lint 检查资源 )(一)
【Android 安装包优化】移除无用资源 ( 自动移除无用资源 | 直接引用资源 | 动态获取资源 id | Lint 检查资源 )(一)
407 0
【Android 安装包优化】移除无用资源 ( 自动移除无用资源 | 直接引用资源 | 动态获取资源 id | Lint 检查资源 )(一)
|
Java jvm-sandbox Shell
Jvm-Sandbox源码分析--增强目标类
在前两篇文章Jvm-Sandbox源码分析--启动简析和Jvm-Sandbox源码分析--启动时加载模块中我们分析了jvm-sandbox启动及启动时加载模块的过程,这一篇我们来看一下如何使用模块增强目标类的流程。
4374 0
|
Web App开发 监控 JavaScript
Fundebug支付宝小程序BUG监控插件更新至0.2.0,新增test()方法,报错增加Page数据
摘要: 0.2.0新增fundebug.test()方法,同时报错增加了Page数据。 Fundebug提供专业支付宝小程序BUG监控服务,可以第一时间为您捕获生存环境中小程序的异常、错误或者BUG,及时给开发者发送报警,帮助您快速修复BUG。
1264 0