I'm trying to make a little close simplification, and I seem to have missed something basic. I want the following snippet:
let updateStackView = NSStackView(views: [updateField])
updateStackView.orientation = .horizontal
updateStackView.distribution = .fill
updateStackView.alignment = .centerX
to look more like this:
let updateStackView = stack(views[updateField], orient: .horizontal, dist: .fill, align: .centerX)
func stack(views:[NSView],
orient: NSUserInterfaceLayoutOrientation,
dist: NSStackView.Distribution,
align: NSLayoutConstraint.Attribute) -> NSStackView {
let s = NSStackView(views: views)
s.orientation = orient
s.distribution = dist
s.alignment = align
return s
}
But, the returned StackView does not get the attributes assigned. What am I missing?
The original snippet works as expected. The factored code doesn't.