A strong reference cycle is where the instances of two classes hold a strong reference to each other, preventing ARC from releasing either instance. Once again, we are not able to use a Playground for this example, so we need to create an Xcode project. In this project, we start off by creating two classes named MyClass1_Strong and MyClass2_Strong with the following code:
class MyClass1_Strong {
var name = ""
var class2: MyClass2_Strong?
init(name: String) {
self.name = name
print("Initializing class1_Strong with name \(self.name)")
}
deinit {
print("Releasing class1_Strong with name \(self.name)")
}
}
class MyClass2_Strong {
var name = ""
var class1: MyClass1_Strong?
init(name: String) {
self.name = name
print("Initializing class2_Strong with name ...