-1

In this case, weakself is needed to avoid retain cycle

[self showMethodA:^{
    [weakself showMethodB];
}];

Will this case cause a retain cycle?

[super showMethodA:^{
    [self showMethodB];
}];
rmaddy
  • 314,917
  • 42
  • 532
  • 579
Ted
  • 22,696
  • 11
  • 95
  • 109

2 Answers2

3

Does it create a cycle? Only if showMethodA stores the block into self.

"super" vs. "self" only affects the dispatching, calling the superclass showMethodA instead of self's own showMethodA. It doesn't affect cycles. And whether a cycle is created or not depends on the code in showMethodA.

gnasher729
  • 51,477
  • 5
  • 75
  • 98
1

Yes it will create retain cycle.

You only create a retain cycle if you actually store the block (because self points to the block, and block points to self).

Refer below link for more info :

Referring to weak self inside a nested block

Community
  • 1
  • 1
Payal Maniyar
  • 4,293
  • 3
  • 25
  • 51