I am trying to retrieve a list of all the properties that my class or any of its subclasses define. The following code snippet is the code that I have been using, and it has worked properly all the way until the recent iOS8 beta 4.
if(!dictionary) {
dictionary = [NSMutableDictionary dictionary];
// Get all properties we have until we hit CBLNestedModel
while(klass != [CBLNestedModel class]) {
unsigned count;
objc_property_t* properties = class_copyPropertyList(klass, &count);
for (unsigned i = 0; i < count; i++) {
objc_property_t property = properties[i];
const char* propertyNameC = property_getName(property);
NSString* propertyName = [NSString stringWithUTF8String:propertyNameC];
const char* propertyAttrC = property_getAttributes(property);
NSString* propertyAttrS = [NSString stringWithUTF8String:propertyAttrC];
NSArray* propertyAttr = [propertyAttrS componentsSeparatedByString:@","];
NSLog(@"%@ has property %@", NSStringFromClass(klass), propertyName);
dictionary[propertyName] = propertyAttr;
}
free(properties);
klass = [klass superclass];
}
propertyDictionary[klassString] = dictionary;
}
CBLNestedModel derives from NSObject. Basically, I want all properties that any subclass of CBLNestedModel declares, or its subclasses. The issue that I'm facing is that now, this code is returning extraneous properties that are not defined in my subclasses.. propertyNames are coming back with @"superclass", @"description", @"debugDescription", @"hash"
for certain classes, even though I have never defined these properties anywhere in my subclasses.
A weird thing is that these extraneous properties are not returned for all subclasses of CBLNestedModel, but only for certain subclasses. However, they will reliably be returned for those subclasses on every run of my app.
Any idea why this is happening now?