Solution for Ch31 Challenge: Boxless NerdTabViewController


#1

Update class NerdTabViewController

//  var box = NSBox()
var box = NSView()

Update selectTabAtIndex(_:slight_smile:

let viewController = childViewControllers[index]
//    box.contentView = viewController.view
let childView = viewController.view
box.subviews = []
box.addSubview(childView)
viewController.view.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "H:|[CV]|", options: [], metrics: nil, views: ["CV":childView]))
NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "V:|[CV]|", options: [], metrics: nil, views: ["CV":childView]))

Update reset()

//    box.borderType = .noBorder
//    box.boxType = .custom

#2

Isn’t separator still using NSBox? I might be making this harder than it is, but how do you make a separator with an NSView? Or is the intent of this Challenge just to replace the childViews as you’ve shown?


#3

Ok, I have removed ‘separator’ from the program and it still runs normally. This completely removes all instances of NSBox. Makes me wonder what the point is of having ‘separator’ in the program if there is no visible difference without it.