Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Views store arrays of their children. Retrieve these arrays by calling [aView subviews]. Onscreen, the child views are always drawn after the parent, in the order that they appear in the subviews array. These views draw in order from back to front, and the subviews array mirrors that drawing pattern. Views that appear later in the array are drawn after views that appear earlier.
The subviews method returns just those views that are immediate children of a given view. At times, you may want to retrieve a more exhaustive list of subviews, including the children’s children. Recipe 6-2 introduces allSubviews(), a simple recursive function that returns a full list of descendants for any view. Call this function with a view’s window (via view.window) to return a complete set of views appearing in the UIWindow that hosts that view. This list proves useful when you want to search for a particular view, such as a specific slider or button.