Felix's Space

Never send to know for whom the bells tolls; it tolls for thee.

有关block

iOS

block发生引用循环

一个对象中强引用了block,在block中又使用了该对象,就会发生循环引用。解决方法就是将该对象使用 __weak或者 __block 修饰符修饰后在block中使用。

  1. id weak weakSelf = self, 或者 weak __typeof(&*self)weakSelf = self (可以将该方法设置为宏)
  2. id __block weakSelf = self;

29 Jun 2014 #iOS #block