Skip to content

Instantly share code, notes, and snippets.

@KentarouKanno
Last active May 8, 2016 03:52
Show Gist options
  • Save KentarouKanno/80f56efd7e591e24a02f326442250b3a to your computer and use it in GitHub Desktop.
Save KentarouKanno/80f56efd7e591e24a02f326442250b3a to your computer and use it in GitHub Desktop.
循環参照

循環参照

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        let myClass1: MyClass? = MyClass()
        let myClass2: MyClass? = MyClass()
        let myClass3: MyClass? = MyClass()
        
        myClass1?.next = myClass2
        myClass2?.next = myClass3
        myClass3?.next = myClass1
    }
}

class MyClass {
    var next: MyClass?
    deinit {
        print("deinit")
    }
}

Xcode > Open Developer Tool > Instruments => Leaks

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment