iOS内存管理 - 澄清 [英] iOS memory management - clarifications
本文介绍了iOS内存管理 - 澄清的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道 alloc
和 retain
会增加对象的引用计数。是否有任何其他方法实际增加引用计数?何时/如何调用 dealloc
?
I know that alloc
and retain
will increase the reference count of an object. Is there any other different method that actually increment the reference count? And when/how does dealloc
is called?
推荐答案
这些是保留计数增加。
-
new,但可以看作是alloc + init。
new, however it can be seen as alloc+init.
保留
复制创建新对象,保留计数= 1
copy creates new object with retain count=1
mutableCopy创建新对象,保留计数= 1
mutableCopy creates new object with retain count=1
dealloc <一旦保留计数达到0,就会自动调用/ code>。
dealloc
is called automatically as soon as retain count reaches to 0.
这篇关于iOS内存管理 - 澄清的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文