都知道这是循环引用的问题,是不是你的潜意识解决办法都会__weak解决,弱引用就好了?

看看我的循环引用的场景:

Capturing 'self' strongly in this block is likely to lead to a retain cycle

 

Capturing 'self' strongly in this block is likely to lead to a retain cycle

一开始想到的解决办法就是: 

__weak typeof(self) weakSelf = self;

发现并不能解决,因为我的属性变量不是Property定义的。

解决办法如下:

__block AddQuesTypeViewController *blockSelf = self;

NSString *str = [NSString stringWithFormat:@"(共%ld题, 共%ld分)", blockSelf -> questionNumber, blockSelf -> score];

以前总以为只有在Block里使用self才会产生循环引用,还是太年轻????

相关文章:

  • 2022-12-23
  • 2021-05-22
  • 2021-05-17
  • 2021-11-01
  • 2021-08-27
  • 2021-09-24
  • 2021-08-11
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-12
  • 2022-12-23
  • 2021-09-04
  • 2021-08-11
相关资源
相似解决方案