【发布时间】:2017-09-18 23:42:01
【问题描述】:
我最近用过
Array.forEach{ $0.isHidden = false }
使用 Swift 3 在 Xcode 8 中为 macOS 使用 NSTextFields 的函数。我正在尝试对 NSBoxes 做同样的事情。这是我正在做的事情:
let Boxes: [NSBox] = [notesBox, manualEditBox, addSubmasterAutoBox, submasterFileDetailsBox]
Boxes.forEach{$0.isTransparent = false}
在第二行,它给了我一个错误,说“不能在属性初始化程序中使用实例成员 'notesBox',属性初始化程序在 'self' 可用之前运行。” 我可以保证所有这些 NSBox 都正确链接并使用 @IBAction 正确引用。
【问题讨论】:
-
我什至不知道notesBox或manualEditBox是什么。
-
@ElTomato 这些是我的 NSBoxes 的名称
-
发帖前请search on your error。
-
可能是stackoverflow.com/questions/25854300/…的副本,但需要查看更多代码才能确定。
-
没有更多上下文,很难判断出什么问题。从错误来看,您似乎没有正确设置自定义初始化程序,但没有看到更多代码,无法确定。