You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
740 B
25 lines
740 B
1 year ago
|
//
|
||
|
// NSTimer+XRTimer.m
|
||
|
// tongxin
|
||
|
//
|
||
|
// Created by Apple on 2020/4/11.
|
||
|
// Copyright © 2020 xTT. All rights reserved.
|
||
|
//
|
||
|
|
||
|
#import "NSTimer+XRTimer.h"
|
||
|
|
||
|
@implementation NSTimer (XRTimer)
|
||
|
|
||
|
+ (NSTimer *)xr_timerWithTimeInterval:(NSTimeInterval)interval repeats:(BOOL)repeats block:(void (^)(NSTimer *))block {
|
||
|
if ([self respondsToSelector:@selector(timerWithTimeInterval:repeats:block:)]) {
|
||
|
return [self timerWithTimeInterval:interval repeats:repeats block:block];
|
||
|
}
|
||
|
return [self timerWithTimeInterval:interval target:self selector:@selector(timerAction:) userInfo:block repeats:repeats];
|
||
|
}
|
||
|
|
||
|
+ (void)timerAction:(NSTimer *)timer {
|
||
|
void (^block)(NSTimer *timer) = timer.userInfo;
|
||
|
if (block) block(timer);
|
||
|
}
|
||
|
@end
|