当引用类型的属性具有相互较强的所有权(或具有闭包)时,会发生Swift中的引用循环.
但是,是否有可能只使用值类型的参考周期?
我在游乐场尝试了这个没有成功(错误:不允许递归值类型'A').
struct A {
var otherA: A? = nil
init() {
otherA = A()
}
}
Run Code Online (Sandbox Code Playgroud) reference-counting value-type reference-type automatic-ref-counting swift