[UIView animateWithDuration:0.2 animations:^{
self.movingView.transform = CGAffineTransformMakeTranslation(200, 0);
}];
非常常用的一个动画block.
那么,在动画 block 中使用了成员变量,会导致 retain cycle 吗?
曾经蜡笔没有小新2017-04-24 16:02:38
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
phpcn_u15822017-04-24 16:02:38
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.