March 2014
Intermediate to advanced
672 pages
40h 11m
English
Each view knows both its parent (aView.superview) and its children (aView.subviews). You can build a view tree, like the one shown in Listing 4-1, by recursively walking through a view’s subviews. Recipe 4-1 builds a visual tree by noting the class of each view and increasing the indentation level every time it moves down from a parent view to its children. The results are stored in a mutable string and returned to the calling method.
The code shown in Recipe 4-1 was used to create the tree shown in Listing 4-1. You can use this method to duplicate the results of Listing 4-1, or you can copy it to other applications to view their hierarchies.
Note
UIView includes a “secret” method—recursiveDescription ...
Read now
Unlock full access