subviews
The array of views embedded in the current view.
Declaration
var subviews: [NSView] { get set }Discussion
This array contains zero or more NSView objects that represent the views embedded in the current view’s content. The current view acts as the superview for each subview. The order of the subviews may be considered as being back-to-front, but this does not imply invalidation and drawing behavior.
When loading a view from a nib or storyboard file, the order of subviews is determined by the nib or storyboard file itself and usually corresponds to the order in which the views were added. Similarly, when adding subviews programmatically, the order is based on the order in which you added them.
When performing hit-test operations on a view, you should start at the last view in this array and work backwards.
Set this property to reorder the view’s existing subviews, add or remove subviews en masse, replace all of the view’s subviews with a new set of subviews, or remove all the view’s subviews. When you assign a valid, new array of subviews, the system performs required sorting and sends addSubview(_:) and removeFromSuperview() messages as necessary to leave the property with the requested new array. Any member of the new array that isn’t already a subview of the view is added. Any member of the view’s existing subviews array that isn’t in the new array is removed. Any views that are in both subviews and the new array are moved in the subviews array as needed, without being removed and re-added.
This property marks the affected view and window areas as needing display.