Inherits from NSObject
Declared in JAGPropertyFinder.h
JAGPropertyFinder.m

Overview

JAGPropertyFinder examines classes and returns a JAGProperty for each property.

Given a class and subclass like:

 @interface MyClass : NSObject

 @property (strong) NSArray *things;
 @property (strong) MyClass *anotherOne;
 @property (assign) int count;
 @property (copy) NSString *title;

 @end

 @interface MySubclass : MyClass

 @property (copy) NSString *subtitle;
 @property (assign) BOOL fun;

 @end

JAGPropertyFinder can give you an NSArray of all these properties, the JAGProperty for a single property, or those properties just contained within the class.

For example, you can do the following:

 NSArray *myClassProps = [JAGPropertyFinder propertiesForClass: [MyClass class]];
 // myClassProps is an NSArray of 4 JAGProperty objects, one for each of
 // things, anotherOne, count, title

 NSArray *mySubclassOnlyProps = [JAGPropertyFinder propertiesForSubclass: [MySubclass class]];
 // mySubclassOnlyProps is an NSArray of 2 JAGProperty objects, one for each of
 // subtitle, fun

 NSArray *mySubclassProps = [JAGPropertyFinder propertiesForClass: [MySubclass class]];
 // mySubclassProps is an NSArray of 6 JAGProperty objects, one for each of
 // things, anotherOne, count, title, subtitle, fun

 JAGProperty *thingsProperty = [JAGPropertyFinder propertyForName:@"things" inClass: [MyClass class]];
 // You can find out information about this property.

 JAGProperty *thingsSubproperty = [JAGPropertyFinder propertyForName:@"things" inClass: [MySubclass class]];
 if ([thingsSubproperty isEqualTo:thingsProperty]) NSLog(@"They are the same!");
 // Properties are accessible on subclasses as well.

 NSArray *propertyNames = [JAGPropertyFinder propertyNamesForClass:[MySubclass class]];
 // [ @"subtitle", @"fun", @"things", @"anotherOne", @"count", @"title" ]

Tasks

Class Methods

propertiesForClass:

The properties defined for this class, including those defined in its superclasses.

+ (NSArray *)propertiesForClass:(Class)aClass

Parameters

aClass

Class with the properties.

Return Value

NSArray of JAGProperty objects defined for this class.

Discussion

It skips properties defined in NSObject.

Declared In

JAGPropertyFinder.h

propertiesForSubclass:

The properties defined explicitly in the subclass.

+ (NSArray *)propertiesForSubclass:(Class)subclass

Parameters

subclass

Class that defines the properties.

Return Value

NSArray of JAGProperty objects defined in this subclass.

Discussion

This does not return those properties defined in any superclasses.

Declared In

JAGPropertyFinder.h

propertyForName:inClass:

The property for the class with the given name.

+ (JAGProperty *)propertyForName:(NSString *)name inClass:(Class)aClass

Parameters

name

Name of property to return.

aClass

Class with the property.

Return Value

JAGProperty defined in this subclass with the given name, or nil if not found.

Discussion

This will also return properties defined in the superclasses, NSObject included.

Declared In

JAGPropertyFinder.h

propertyNamesForClass:

The names of the properties defined for this class.

+ (NSArray *)propertyNamesForClass:(Class)aClass

Parameters

aClass

the class containing the properties.

Return Value

NSArray of NSString objects with the property names.

Discussion

This includes those defined for its superclasses, excluding NSObject.

Declared In

JAGPropertyFinder.h