How does the new automatic reference counting mechanism work?

后端 未结 6 2058
粉色の甜心
粉色の甜心 2020-11-22 11:08

Can someone briefly explain to me how ARC works? I know it\'s different from Garbage Collection, but I was just wondering exactly how it worked.

Also, if ARC does wh

6条回答
  •  悲哀的现实
    2020-11-22 11:47

    Very well explained by Apple developer documentation. Read "How ARC Works"

    To make sure that instances don’t disappear while they are still needed, ARC tracks how many properties, constants, and variables are currently referring to each class instance. ARC will not deallocate an instance as long as at least one active reference to that instance still exists.

    To make sure that instances don’t disappear while they are still needed, ARC tracks how many properties, constants, and variables are currently referring to each class instance. ARC will not deallocate an instance as long as at least one active reference to that instance still exists.

    To know Diff. between Garbage collection and ARC: Read this

提交回复
热议问题