I have recently used the
Array.forEach{ $0.isHidden = false }
function with NSTextFields for macOS in Xcode 8 using Swift 3. I am trying to do the same thing with NSBoxes. Here is what I am doing:
let Boxes: [NSBox] = [notesBox, manualEditBox, addSubmasterAutoBox, submasterFileDetailsBox]
Boxes.forEach{$0.isTransparent = false}
At the second line, it is giving me an error saying "Cannot use instance member 'notesBox' within property initializer, property initializers run before 'self' is available." I can guarantee that all of these NSBoxes are linked properly and properly referenced using @IBAction.
Make sure you don't try to initialize the contents of the array at the scope of the controller. You have to declare the array and then populate it with other properties (i.e. the boxes) in viewDidLoad or whatever method suits you best.