An object that manages an array of adjacent child views, and has a split view object for managing dividers between those views.


class NSSplitViewController : NSViewController


The complete object architecture of a split view controller is a bit more complex. Specifically, a split view controller owns an array of split view items (of type NSSplitViewItem), each of which has a view controller (of type NSViewController) and corresponding view. The child views and the dividers are all contained within the split view controller’s own view.

The split view controller serves as the delegate of its split view object (the object that manages the dividers). If you override a split view delegate method, your override must call super.

By default, child views are arranged vertically, from top to bottom in the split view controller’s view. To specify horizontal (side-by-side) arrangement, implement the vertical property of the split view controller’s splitView object to return true (returning true specifies vertical dividers and, consequently, horizontal view arrangement).

To use a split view controller, you must use Auto Layout for the child views and to support animations that collapse and reveal child views. For example, if you design a layout containing two views, a content area and an optional sidebar, you would employ Auto Layout constraints to specify whether the content area shrinks or remains the same size when the sidebar becomes visible.

A split view controller employs lazy loading of its views. For example, adding a collapsed split view item as a new child does not load the associated view until it is revealed.

For more information about using NSSplitViewController in your app, see Navigating Hierarchical Data Using Outline and Split Views.


Configuring and Managing a Split View Controller

var splitView: NSSplitView

The split view managed by the split view controller.

func splitViewItem(for: NSViewController) -> NSSplitViewItem?

Returns the corresponding split view item for a given child view controller of the split view controller.

var splitViewItems: [NSSplitViewItem]

The array of split view items that correspond to the split view controller’s child view controllers.

Modifying a Split View Controller

func addSplitViewItem(NSSplitViewItem)

Adds a split view item to the end of the splitViewItems array of the split view controller.

func insertSplitViewItem(NSSplitViewItem, at: Int)

Adds a split view item to the splitViewItems array of the split view controller, at a specified index position.

func removeSplitViewItem(NSSplitViewItem)

Removes a specified split view item from the split view controller.

See Also

Split View Interface

class NSSplitView

A view that arranges two or more views in a linear stack running horizontally or vertically.

class NSSplitViewItem

An item in a split view controller.