mirror of
https://github.com/GLEGram/GLEGram-iOS.git
synced 2026-04-24 11:56:18 +02:00
4647310322
Based on Swiftgram 12.5 (Telegram iOS 12.5). All GLEGram features ported and organized in GLEGram/ folder. Features: Ghost Mode, Saved Deleted Messages, Content Protection Bypass, Font Replacement, Fake Profile, Chat Export, Plugin System, and more. See CHANGELOG_12.5.md for full details.
34 lines
1.2 KiB
Objective-C
34 lines
1.2 KiB
Objective-C
#import <LegacyComponents/TGTimerTarget.h>
|
|
|
|
@implementation TGTimerTarget
|
|
|
|
+ (NSTimer *)scheduledMainThreadTimerWithTarget:(id)target action:(SEL)action interval:(NSTimeInterval)interval repeat:(bool)repeat
|
|
{
|
|
return [self scheduledMainThreadTimerWithTarget:target action:action interval:interval repeat:repeat runLoopModes:NSRunLoopCommonModes];
|
|
}
|
|
|
|
+ (NSTimer *)scheduledMainThreadTimerWithTarget:(id)target action:(SEL)action interval:(NSTimeInterval)interval repeat:(bool)repeat runLoopModes:(NSString *)runLoopModes
|
|
{
|
|
TGTimerTarget *timerTarget = [[TGTimerTarget alloc] init];
|
|
timerTarget.target = target;
|
|
timerTarget.action = action;
|
|
|
|
NSTimer *timer = [[NSTimer alloc] initWithFireDate:[NSDate dateWithTimeIntervalSinceNow:interval] interval:interval target:timerTarget selector:@selector(timerEvent) userInfo:nil repeats:repeat];
|
|
[[NSRunLoop mainRunLoop] addTimer:timer forMode:runLoopModes];
|
|
return timer;
|
|
}
|
|
|
|
- (void)timerEvent
|
|
{
|
|
id target = _target;
|
|
if ([target respondsToSelector:_action])
|
|
{
|
|
#pragma clang diagnostic push
|
|
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
|
|
[target performSelector:_action];
|
|
#pragma clang diagnostic pop
|
|
}
|
|
}
|
|
|
|
@end
|