iOS:fix timer invalid

This commit is contained in:
pengfei.zhou 2020-04-20 15:03:34 +08:00 committed by osborn
parent de9b96c490
commit 2c2d3e4113

View File

@ -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];