iOS Runtime获取对象所有key值

1.引入库
#include <objc/runtime.h>
2.以系统对象为例,正常情况下我们无法查看系统对象的私有属性,如下方法可以得到其全部属性。

以相册的PHAsset为例:

for (PHAsset *asset inself.assetsFetchResults) {
    unsigned int count;
    // 获取属性列表
    objc_property_t *propertyList = class_copyPropertyList([asset class], &count);
    for (unsigned int i = 0; i<count; i++) {
        const char *propertyName = property_getName(propertyList[i]);
        NSLog(@"property----="">%@", [NSString stringWithUTF8String:propertyName]);
    }   
}
打印的部分属性
 property----=>avalanchePickType
 property----=>locationData
 property----=>savedAssetType
 property----=>cloudIsDeletable
 property----=>sceneClassifications
 property----=>distanceIdentity
 property----=>curationScore
 property----=>locationCoordinate
 property----=>imageOrientation
 property----=>aspectRatio
 property----=>uniformTypeIdentifier
 property----=>persistenceState
 ..........
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 国家电网公司企业标准(Q/GDW)- 面向对象的用电信息数据交换协议 - 报批稿:20170802 前言: 排版 ...
    庭说阅读 14,020评论 6 13
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 176,093评论 25 709
  • 在人生的旅途当中,在工作上、在生活上,冲突无法避免,但是有效的冲突管理,却可以让伤害降低到最小。 冲突管理四部曲:...
    周明达老师阅读 5,579评论 1 6
  • 过年之旅——陕西袁家村
    无声静候阅读 3,301评论 0 1
  • 1、从文章中学到的重要概念 1)优先考虑重要的事,学会全面发展,学会小组合作。 2)态度决定学习道路,...
    南沐槿阅读 1,801评论 1 0

友情链接更多精彩内容