我有一个结构设置,接受一个引用作为单个初始化参数:
internal struct NodeState: Equatable { weak var node: Node! = nil // ... init(node: Node) { self.node = node } }
我想将NodeState实例化为Node类的成员,传递self in来设置弱引用:
public class Node: NSObject { internal var state = NodeState(node: self) // ... }
…但是我得到了这个奇怪的编译错误:
Cannot convert value of type ‘NSObject -> () -> Node’ to expected argument type ‘Node’
我不允许在Swift的成员声明中引用self吗?