转自StackOverFlow
#import <objc/runtime.h>
- (void)yourMethod{
UIView *parnetView = ...;
[parentView.subviews makeObjectsPerformSelector:@selector(printAllProperties)];
}
@interface UIView (printAllProperties)
- (void) printAllProperties;
@end
@implementation UIView (printAllProperties)
-(void)printAllProperties{
dispatch_async(dispatch_get_global_queue(0, 0), ^{
unsigned int numberOfProperties = 0;
objc_property_t *propertyArray = class_copyPropertyList([self class], &numberOfProperties);
for (NSUInteger i = 0; i < numberOfProperties; i++) {
objc_property_t property = propertyArray[i];
NSString *name = [[NSString alloc] initWithUTF8String:property_getName(property)];
NSLog(@"Property %@ Value: %@", name, [self valueForKey:name]);
}
free(propertyArray);
});
}
@end
You need to add method printAllProperties as category to UIView
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)