From db778b1d70b3ee74de8bfeedbad9aadd5d4280f4 Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Fri, 21 Aug 2020 12:58:42 -0400 Subject: [PATCH] prevent retain cycle on auto dismiss block. --- MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m index 1581edc5..55841e3f 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m @@ -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]; } } });