objective-c - block内存管理的问题
PHP中文网
PHP中文网 2017-04-24 16:00:38
0
3
764
[UIView animateWithDuration:0.2 animations:^{
    self.movingView.transform = CGAffineTransformMakeTranslation(200, 0);
}];

非常常用的一个动画block.

那么,在动画 block 中使用了成员变量,会导致 retain cycle 吗?

PHP中文网
PHP中文网

认证0级讲师

reply all(3)
曾经蜡笔没有小新

The so-called "reference cycle" refers to two-way strong references, so those "one-way strong references" (block strong reference self) are no problem

It is recommended to read the following link, question 39, which is very detailed
"Recruiting a reliable iOS" interview question reference answer

过去多啦不再A梦

If it’s arc it won’t

phpcn_u1582

If it is arc, then this problem will occur ~ mrc will not.

Because the member variable you use looks like this to the compiler: self->member. Therefore, in arc mode, although only member variables are used, self actually points to this variable, and there is still a memory leak problem.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template