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.
This commit is contained in:
Michael
2024-07-03 20:28:11 -04:00
parent f3faeff951
commit 3c0abb0dcf
+5 -1
View File
@@ -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 -