Confused about a situation that might be a retain cycle?
I understand that if
class Object-A {
var b: Object-B }
and
class Object-B {
var a: Object-A
]
then above is horrible design because if you do
var a = Object-A()
var b = Object-B()
a.b = b
b.a = a
then this causes a retain cycle with two strong references pointing at each other.
But what if the situation is below?
class Object-A {
var b: Object-B
}
class Object-B {
var randomArrayProperty: [Object-B]
}
and you try to do
var a = Object-A()
var b = Object-B()
a.b = a
b.randomArrayProperty.append(a)
Is that a retain cycle as well?
Generally speaking, with manual reference counting and automatic reference counting, reference ilands will leak. Reference cycle can be composed by more than just 2 objects.
That said I encourage you to test some code in a playground since the example in your question has some syntax and language errors.
The code below might be a starting point:
Then continue playing with variants ;-)
Hope this helps