Is there support for NSSplitViewController/NSSplitViewItem for XIBs? I see only NSSplitView
Can I just drag&drop NSViewController and subclass it as NSSplitViewController? How do I add NSSplitViewItem that it mostly works out of the box?
I can easily see support for them in storyboards.



Yes it's possible. But it needs some wiring.
First add a custom subclass of
NSSplitViewItemand exposeviewControllerproperty as IBOutlet. Compiler will throw a warning so don't forget to mark property as dynamic.In your XIB add 3 NSViewController objects. One of them change to custom class NSSplitViewController. It is important to note that one should NOT add
NSSplitView. WireNSViewControllersto it'sviews. Also add 2 objects and add custom class ofMySplitViewItemwhich has exposed theviewControllerand wire it.Last step. It is important to set property
splitItemsofNSSplitViewControllerbefore the views are loaded! Otherwise you are caught with NSAssert macro.Here is a proof that everything is wired correctly. Note that I did not touch delegate in XIB and it is wired. Magic, I know.
PS: XIB has to be set to prefer Coder + auto layout.
Why do I prefer XIB? Because we can create larger XIB which doesn't suffer from data isolation (Easily can do bindings across NSViewControllers).
I have also experimented to add
splitViewItemsinviewDidLoadorsetVieworawakeFromNib: in custom subclass ofNSSplitViewController(with exposed NSSplitViewItem properties). If someone finds solution here it will be greatly appreciated.Solution that requires code only: