prevent retain cycle on auto dismiss block.

This commit is contained in:
Kyle Matthew Hedden 2020-08-21 12:58:42 -04:00
parent 1196608e25
commit db778b1d70

View File

@ -347,12 +347,13 @@
}
dispatch_time_t dispatchTime = dispatch_time(DISPATCH_TIME_NOW, dismissTime * NSEC_PER_SEC);
dispatch_after(dispatchTime, dispatch_get_main_queue(), ^(void){
if (weakSelf && weakSelf.expanded && weakSelf.collapseAutomaticallyAfterExpanded) {
typeof(self) strongSelf = weakSelf;
if (strongSelf && strongSelf.expanded && strongSelf.collapseAutomaticallyAfterExpanded) {
// If accessibility focused, delay collapse.
if ([MVMCoreUIUtility viewContainsAccessiblityFocus:self]) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(accessibilityFocusChanged:) name:UIAccessibilityElementFocusedNotification object:nil];
if ([MVMCoreUIUtility viewContainsAccessiblityFocus:strongSelf]) {
[[NSNotificationCenter defaultCenter] addObserver:strongSelf selector:@selector(accessibilityFocusChanged:) name:UIAccessibilityElementFocusedNotification object:nil];
} else {
[weakSelf collapse];
[strongSelf collapse];
}
}
});