Iām trying to write a text file with name of all the views contains in the Screen. For example
I have a UIView
in which I have 2 UIButtons
so the file should be as bellow..
UIWindow
UIView
UIButton
UIButtonLabel
UIButton
UIButtonLabel
_UILayoutGuide
_UILayoutGuide
This is how I'm trying to do but the above hierarchy I'm unable to achieve.
-(void) writeViewHierarchyForView:(UIView *)aView inString:( NSMutableString *)str
{
//NSMutableString *str = [[NSMutableString alloc] init];
NSLog(@"title Text = %@", aView.titleText);
if(nil == aView.children){
[str appendString:@"\n"];
return;
}
else{
for(UIView *view in aView.subview){
[str appendString:@"\n\t"];
[str appendString:view.name];
NSLog(@"%@",view.name);
[str appendString:@"\t"];
[self writeViewHierarchyForView:view inString:str];
}
}
}
this is not something I'm using in any project but doing it just for fun. any suggestion would be great.