From 3c0abb0dcf7c17d04bb8622f3df41f902bcd4b79 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 3 Jul 2024 20:28:11 -0400 Subject: [PATCH] Dereference TVCAlert completion block when alert dismisses TDCAlert holds strong reference to TVCAlert using its completion block. That's how TDCAlert is able to present an alert without the caller having to retain it. We should dereference that completion block in TVCAlert when we are finished to break that reference cycle. --- Sources/App/Classes/Views/Errors/TVCAlert.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sources/App/Classes/Views/Errors/TVCAlert.m b/Sources/App/Classes/Views/Errors/TVCAlert.m index dda3f4f1c..38c9014dd 100755 --- a/Sources/App/Classes/Views/Errors/TVCAlert.m +++ b/Sources/App/Classes/Views/Errors/TVCAlert.m @@ -62,7 +62,7 @@ typedef NS_ENUM(NSUInteger, TVCAlertType) { @property (nonatomic, assign) BOOL alertVisible; @property (nonatomic, assign) BOOL layoutPerformed; @property (nonatomic, assign) TVCAlertType alertType; -@property (nonatomic, copy) TVCAlertCompletionBlock completionBlock; +@property (nonatomic, copy, nullable) TVCAlertCompletionBlock completionBlock; @property (nonatomic, copy, nullable) TVCAlertButtonClickedBlock firstButtonAction; @property (nonatomic, copy, nullable) TVCAlertButtonClickedBlock secondButtonAction; @property (nonatomic, copy, nullable) TVCAlertButtonClickedBlock thirdButtonAction; @@ -473,6 +473,10 @@ typedef NS_ENUM(NSUInteger, TVCAlertType) { LogToConsoleDebug("[%@] Alert dismissed", self); self.alertVisible = NO; + + // Dereference completion block when finished because the + // completion block may be the only reference to self. + self.completionBlock = nil; } #pragma mark -