一般在block中修改变量都需要事先加block进行修饰。
在非arc中,
block修饰的变量的引用计算是不变的。
在arc中,会引用到,并且计算+1;
非arc下可使用(arc直接使用__weak即可)

//非ARC
__block typeof(self) weakSelf = self;
self.myBlock = ^(int paramInt){ 
//使用weakSelf访问self成员
 [weakSelf anotherFunc];
};

这样可以解决循环引用问题。

 

starain Dou 豆电雨

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

原文链接:http://www.jianshu.com/p/2d67c8e3d6d1

相关文章:

  • 2021-10-15
  • 2022-12-23
  • 2021-11-18
  • 2021-08-18
  • 2021-09-25
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-05-21
  • 2022-12-23
  • 2022-12-23
  • 2022-01-11
  • 2022-12-23
相关资源
相似解决方案