在这里,我正在玩泄漏,所以我有意识地做了一个强大的参考周期,看看仪器是否会检测到某些东西,我得到了意想不到的结果.仪器中显示的泄漏确实有意义,但随机崩溃有点神秘(由于我将在后面提到的两个事实).
我这里有一个叫做的课程SomeClass:
class SomeClass{
    //As you can guess, I will use this shady property to make a strong cycle :)
    var closure:(()->())?
    init(){}
    func method(){}
    deinit {print("SomeClass deinited")}
}
我还有两个场景,GameScene:
class GameScene: SKScene {
    override func didMoveToView(view: SKView) {
        backgroundColor = .blackColor()
        let someInstance = SomeClass()
        let closure = {[unowned self] in
            someInstance.method() //This causes the strong reference cycle...
            self.method()  
        }
        someInstance.closure = closure
    }
    override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
        if …