ClassProperty 1.0.1

ClassProperty 1.0.1

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Mar 2015

Maintained by Ravi.



Why use ClassProperty?

Code to fetch all the instance variables and its corresponding type for an Objective-C Class (using Objective-C runtime)

It also supports Super class

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

Author

Ravi Prakash Sahu, [email protected]

License

ClassProperty is available under the MIT license. See the LICENSE file for more info.

Example

Lets say we have three classes

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

Simply import this

#import <ClassProperty/ClassProperty.h>

Sample code

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

OR

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