Seal of strong object owners, Swift

My iOS app has some save loop.

For a specific viewController stuck in a save loop, I tried to make all delegates weak. But when I simulate a memory warning from the simulator, doRecieveMemoryWarning is called, but the deinit method is not called.

I want to print / see the owner of this viewController, which still holds it when doRecieveMemoryWarning is called. Is there a way I can do this.

+4
source share
3 answers

No, there is no way to print the owners of an object, as you describe, at least not quite. iOS does not use garbage collection, it uses ARC (automatic reference counting). The system does not track link ownership in ARC. Instead, every time you add a link to an object for an object, the system increases the retention counter, and every time you clear a personal link, the system decreases, saving the account.

. ( "", , "", "".) , . , , , , . , , SO. WWDC . .

, , (, ) , . .

, . , . .

+2

Xcode 8, Debugger Graph Graph, . Graph Graph, , . enter image description here

WWDC 2016 , 24:30.

https://developer.apple.com/videos/play/wwdc2016/410/

+10

deinit,

class Person {
    let name: String
    init(name: String) {
        self.name = name
        print("\(name) is being initialized")
    }
    deinit {
        print("\(name) is being deinitialized")
    }
}

You can check this: Automatic link counting

-1
source

Source: https://habr.com/ru/post/1621112/


All Articles