一个在 NSObject
上的小分类,它通过 valueForKey:
支持递归查找
NSArray *superviewChain = [view recursiveValueForKey:@"superview"];
// Recursively gets the superview property until it is nil
就像传统的 valueForKey:
方法一样,当使用在集合类(NSArray
、NSSet
和 NSOrderedSet
)上时,它会对集合中的每个对象应用此方法。
NSArray *allSubviews = [view recursiveValueForKey:@"subviews"];
// Returns all the subviews of a view, and all their subviews, and all their subviews, etc.