Skip to content

Instantly share code, notes, and snippets.

@jebai0521
Created July 8, 2020 01:14
Show Gist options
  • Save jebai0521/2a3f3c4d228bac4adac25bae393a4f70 to your computer and use it in GitHub Desktop.
Save jebai0521/2a3f3c4d228bac4adac25bae393a4f70 to your computer and use it in GitHub Desktop.
- (NSArray *)objectProperties:(NSObject *)object {
// RCTLog(@"objectProperties %@ %@ Enter", object, object.class);
NSMutableArray* properties = [NSMutableArray new];
unsigned int count;
Class cls = [object class];
// RCTLog(@"objectProperties %@", cls);
do {
// RCTLog(@"objectProperties Current %@", cls);
objc_property_t* props = class_copyPropertyList(cls, &count);
for (int i = 0; i < count; i++) {
objc_property_t property = props[i];
NSString *propertyName = [NSString stringWithCString:property_getName(property) encoding:NSUTF8StringEncoding];
[properties addObject:propertyName];
}
free(props);
cls = [cls superclass];
// RCTLog(@"objectProperties Next %@ ", cls);
} while ([cls isSubclassOfClass:[RNNOptions class]] && cls != nil);
// RCTLog(@"objectProperties %@ Leave %@", cls, properties);
return properties;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment