0

From the NSSplitViewController class reference at https://developer.apple.com/library/prerelease/mac/documentation/AppKit/Reference/NSSplitViewController_Class/index.html I understand that it has a property that is an array of objects oftype NSSplitViewItem. It also has methods to insert and remove NSSplitViewItem objects. However, there is no documentation for NSSplitViewItem. How do I create such an object?

I saw one example online:

let svi = NSSplitViewItem(viewController: vc) where vc is of type NSViewController

But found no Apple documentation at all. It almost seems like Apple wants developers not to programmatically add/remove NSSplitViewItem

Could someone tell me how to create a NSSplitViewItem?

perfopt
  • 65
  • 7
  • With NSSplitViewController you don't have to play with items, you can use addChildViewController: http://stackoverflow.com/a/40708392/3275080 – Peter Ahlberg Nov 20 '16 at 19:39

1 Answers1

2

Somehow no public documentation is available for NSSplitViewItem. But there is a little trick for scenarios like that. Type NSSplitViewItem in Xcode and then ⌘-click it. You will be able to see the 'header file' for NSSplitViewItem.

There are multiple initializers available.

Example:

let item = NSSplitViewItem(viewController: self.viewController)
splitViewController.addSplitViewItem(item)
mangerlahn
  • 4,746
  • 2
  • 26
  • 50