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
..........