Swift object to reference itself (without optionals) -
i trying create object class contain reference self or object:
class myobject { let owner: myobject init(owner: myobject) { self.owner = owner; } } class rootobject : myobject { init() { self.owner = self } } var root = rootobject() var child = myobject(root) // child.owner == root // child.owner.owner == root
is possible modify code , implement idea without use of optionals?
Comments
Post a Comment