jdg / MBProgressHUD

MBProgressHUD + Customizations
http://www.bukovinski.com/
MIT License
16.01k stars 3.56k forks source link

Retain cycle on `self` with blocks inside `-hideUsingAnimation:` method #442

Closed sergeyduhovich closed 6 years ago

sergeyduhovich commented 8 years ago

in method - (void)hideUsingAnimation:(BOOL)animated line 233

now:

[self animateIn:NO withType:self.animationType completion:^(BOOL finished) {
   [self done];
}];

should be:

__weak typeof(self)weakSelf = self;
[self animateIn:NO withType:self.animationType completion:^(BOOL finished) {
   __strong typeof(self)strongSelf = weakSelf;
   [strongSelf done];
}];
fysteven commented 7 years ago

The block is a NSStackBlock, so don't worry about the method call inside the block. It's not a retain cycle.

matej commented 6 years ago

This is intentional. We do want to keep the hud around until the block is called.