Reference cycles with value types?

后端 未结 6 1417
太阳男子
太阳男子 2020-12-03 08:34

Reference cycles in Swift occur when properties of reference types have strong ownership of each other (or with closures).

Is there, however, a possibility of havin

6条回答
  •  没有蜡笔的小新
    2020-12-03 09:00

    Is there, however, a possibility of having reference cycles with value types only?

    Depends on what you mean with "value types only". If you mean completely no reference including hidden ones inside, then the answer is NO. To make a reference cycle, you need at least one reference.

    But in Swift, Array, String or some other types are value types, which may contain references inside their instances. If your "value types" includes such types, the answer is YES.

提交回复
热议问题