// // 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