Why does setFrame increase the layer's reference score?

Running this code:

mainLyr = [[CALayer layer] retain];
[mainLyr setFrame:CGRectMake(0.0,0.0,23.0,23.0)];

      

in the debugger I found that after retain

the reference count mainLyr

is 2. This is correct.

But after that, setFrame

the link count increased to 3. Why? And how do I know if a method will increment or decrement the reference count (can't find this in the reference manual).

0


source to share


2 answers


As it has been said many times on stackoverflow, don't rely on refcount for memory management. Follow the rules of memory management and you will be fine.



+4


source


Graham is right, but the reason he increases the link count is because you are using Core Animation here; the change in arithmetic on the layer is animated and the target is preserved during animation. After the animation duration (default 0.25s in my opinion), your reference count should go down by 1.



+4


source







All Articles