Skip to content

Commit

Permalink
Fix bug in TyphoonCollaboratingAssemblyPropertyEnumerator
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasper Blues committed Jan 27, 2014
1 parent 45309b0 commit 850caf4
Showing 1 changed file with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,29 @@ @implementation TyphoonCollaboratingAssemblyPropertyEnumerator
- (id)initWithAssembly:(TyphoonAssembly*)assembly
{
self = [super init];
if (self) {
if (self)
{
_assembly = assembly;
}
return self;
}

- (NSSet *)collaboratingAssemblyProperties
- (NSSet*)collaboratingAssemblyProperties
{
NSMutableSet *propertyNames = [[NSMutableSet alloc] init];
NSMutableSet* propertyNames = [[NSMutableSet alloc] init];

Class class = [self.assembly class];
while ([self classNotRootAssemblyClass:class])
{
unsigned int count = 0;
objc_property_t * properties = class_copyPropertyList(class, &count);
for (int propertyIndex = 0; propertyIndex < count; propertyIndex++) {
objc_property_t* properties = class_copyPropertyList(class, &count);
for (int propertyIndex = 0; propertyIndex < count; propertyIndex++)
{
objc_property_t aProperty = properties[propertyIndex];

NSString *propertyName = [self propertyNameForProperty:aProperty];
if ([self propertyForName:propertyName isCollaboratingAssemblyPropertyOnClass:class]) {
NSString* propertyName = [self propertyNameForProperty:aProperty];
if ([self propertyForName:propertyName isCollaboratingAssemblyPropertyOnClass:class])
{
[propertyNames addObject:propertyName];
}
}
Expand All @@ -58,7 +61,7 @@ - (NSSet *)collaboratingAssemblyProperties
- (BOOL)propertyForName:(NSString*)propertyName isCollaboratingAssemblyPropertyOnClass:(Class)class
{
TyphoonTypeDescriptor* type = [TyphoonIntrospectionUtils typeForPropertyWithName:propertyName inClass:class];
return type.typeBeingDescribed == [TyphoonAssembly class];
return [type.typeBeingDescribed isSubclassOfClass:[TyphoonAssembly class]];
}

- (BOOL)classNotRootAssemblyClass:(Class)class
Expand All @@ -68,7 +71,7 @@ - (BOOL)classNotRootAssemblyClass:(Class)class

- (id)propertyNameForProperty:(objc_property_t)aProperty
{
const char *cPropertyName = property_getName(aProperty);
const char* cPropertyName = property_getName(aProperty);
return [NSString stringWithCString:cPropertyName encoding:NSUTF8StringEncoding];
}

Expand Down

0 comments on commit 850caf4

Please sign in to comment.