Files
featherVoice/TUIKit/TIMCommon/CommonModel/NSTimer+TUISafe.m
2025-08-08 10:49:36 +08:00

22 lines
602 B
Objective-C

//
// NSTimer+TUISafe.m
// TUICore
//
// Created by wyl on 2022/7/5.
// Copyright © 2023 Tencent. All rights reserved.
//
#import "NSTimer+TUISafe.h"
@implementation NSTimer (TUISafe)
+ (NSTimer *)tui_scheduledTimerWithTimeInterval:(NSTimeInterval)interval repeats:(BOOL)repeats block:(void (^)(NSTimer *timer))block {
return [self scheduledTimerWithTimeInterval:interval target:self selector:@selector(tui_callBlock:) userInfo:[block copy] repeats:repeats];
}
+ (void)tui_callBlock:(NSTimer *)timer {
void (^block)(NSTimer *timer) = timer.userInfo;
!block ?: block(timer);
}
@end