From 0d509b73ba0dbbb682b3fa16f53e1bc5ddcbd596 Mon Sep 17 00:00:00 2001 From: Gabriele Mazzotta Date: Tue, 20 Jun 2023 22:39:00 +0200 Subject: [PATCH] Do not use __weak for _restartTimer __weake causes a build error with ARC enabled and disabling ARC causes even more errors. The timer is automatically invalidated when it fires, so we can just set the field to nil when `block` is executed. --- MiddleClick/Controller.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MiddleClick/Controller.m b/MiddleClick/Controller.m index 75dbf9c..a007613 100644 --- a/MiddleClick/Controller.m +++ b/MiddleClick/Controller.m @@ -57,7 +57,7 @@ #pragma mark Implementation @implementation Controller { - NSTimer* _restartTimer __weak; // Using `weak` so that the pointer is automatically set to `nil` when the referenced object is released ( https://en.wikipedia.org/wiki/Automatic_Reference_Counting#Zeroing_Weak_References ). This helps preventing fatal EXC_BAD_ACCESS. + NSTimer* _restartTimer; } - (void)start @@ -209,6 +209,7 @@ - (void)scheduleRestart:(NSTimeInterval)delay _restartTimer = [NSTimer scheduledTimerWithTimeInterval:delay repeats:NO block:^(NSTimer* timer) { + _restartTimer = nil; [self restartListeners]; }]; }