From 2c2d3e4113d33b6e6dc41515f02cabfb1dc18e17 Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Mon, 20 Apr 2020 15:03:34 +0800 Subject: [PATCH] iOS:fix timer invalid --- doric-iOS/Pod/Classes/Engine/DoricJSEngine.m | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/doric-iOS/Pod/Classes/Engine/DoricJSEngine.m b/doric-iOS/Pod/Classes/Engine/DoricJSEngine.m index 97ae29b6..26f925e6 100644 --- a/doric-iOS/Pod/Classes/Engine/DoricJSEngine.m +++ b/doric-iOS/Pod/Classes/Engine/DoricJSEngine.m @@ -224,11 +224,13 @@ - (void)destroyContext:(NSString *)contextId { - (void)callbackTimer:(NSTimer *)timer { __weak typeof(self) _self = self; + if (!timer.isValid) { + return; + } + NSDictionary *userInfo = timer.userInfo; + NSNumber *timerId = [userInfo valueForKey:@"timerId"]; + NSNumber *repeat = [userInfo valueForKey:@"repeat"]; dispatch_async(self.jsQueue, ^() { - NSDictionary *userInfo = timer.userInfo; - NSNumber *timerId = [userInfo valueForKey:@"timerId"]; - NSNumber *repeat = [userInfo valueForKey:@"repeat"]; - __strong typeof(_self) self = _self; @try { [self invokeDoricMethod:DORIC_TIMER_CALLBACK, timerId, nil];