Created
June 14, 2011 14:27
-
-
Save alinradut/1025002 to your computer and use it in GitHub Desktop.
Print all subviews with a certain type
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (NSString *)superviewPath:(UIView *)view | |
| { | |
| NSMutableArray *path = [NSMutableArray array]; | |
| while (view != nil) | |
| { | |
| [path insertObject:[NSString stringWithFormat:@"(%p) %@",view,NSStringFromClass([view class])] atIndex:0]; | |
| view = [view superview]; | |
| } | |
| return [path componentsJoinedByString:@" > "]; | |
| } | |
| - (void)printSubviewsOfView:(UIView *)view withClass:(Class)class | |
| { | |
| for (UIView *subview in [view subviews]) | |
| { | |
| if ([subview isKindOfClass:class]) | |
| { | |
| NSLog(@"%@ descendant : %@", NSStringFromClass(class), [self superviewPath:subview]); | |
| } | |
| [self printSubviewsOfView:subview withClass:class]; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment