How change NSTableView's width using code?

I calculate cell view's width in func tableView(_ tableView: NSTableView, sizeToFitWidthOfColumn column: Int). I have a need to resize the tableview's width to just match total width of all cell views' (without scrollbars).

But it seems changing tableview's width does not work:

tableView.bounds.size = CGSize(width: w, height: tableView.bounds.height)

I suspect that I should change its clipping view or enclosing scrollview, but don't have any idea on this.

Any help?