ClassProperty 1.0.1

ClassProperty 1.0.1

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布上次发布2015年3月

Ravi维护。



为什么使用ClassProperty?

使用Objective-C运行时检索Objective-C类所有实例变量及其对应类型的代码

它也支持超级类

使用方法

要运行示例项目,请克隆仓库,并首先从Example目录运行pod install

安装

作者

Ravi Prakash Sahu,[email protected]

许可证

ClassProperty在MIT许可证下提供。有关更多信息,请参阅LICENSE文件。

示例

假设我们有三个类

RSClassA

@interface RSClassA : NSObject

@property NSString *alpha;
@property NSNumber *beta;
@property NSData *gamma;
@property NSArray *listArray;

@end

RSClassB

@interface RSClassB : RSClassA

@property NSString *intel;
@property NSString *mac;

@end

RSClassC

@interface RSClassC : RSClassB

@property NSInteger count;
@property CGFloat height;
@property NSIndexPath *indexPath;

@end

只需导入此

#import <ClassProperty/ClassProperty.h>

示例代码

NSDictionary *propertyDict = [ClassProperty getPropertyDictionaryForClass:[RSClassC class]];
for (NSString *key in [propertyDict allKeys]) {
    NSLog(@"Key : %@, Type : %@", key, [propertyDict valueForKey:key]);
}

或者

NSDictionary *propertyDict = [ClassProperty getPropertyDictionaryForClass:NSClassFromString(@"RSClassC")];
for (NSString *key in [propertyDict allKeys]) {
    NSLog(@"Key : %@, Type : %@", key, [propertyDict valueForKey:key]);
}