NSTimer implements the clock callback method and nstimer callback
During the development process, it is found that there are many clock calls. Therefore, the clock is encapsulated in a simple and unified manner. The Code is as follows:
1. Declaration of the clock callback function:
# Pragma mark clock callback processing // clock callback + (NSTimer *) lsScheduleTimerWithTimerInternal :( NSTimeInterval) interval block :( void (^) () block repeats :( BOOL) repeats;
2. Implementation of the clock callback function:
/*** @ Brief clock callback * @ param paramete request parameter * interval: interval * repeats: Number of retries * @ return NSTimer */+ (NSTimer *) lsScheduleTimerWithTimerInternal :( NSTimeInterval) interval block :( void (^) () block repeats :( BOOL) repeats {NSTimer * timer = [self scheduledTimerWithTimeInterval: interval target: self selector: @ selector (lsTimerBlockInvoke :) userInfo: [block copy] repeats: repeats]; [[nsunloop currentRunLoop] addTimer: timer forMode: nsunloopcommonmodes]; // retains nstmer class objects and ignores return timer;} + (void) lsTimerBlockInvoke :( NSTimer *) timer {void (^ block) () = timer. userInfo; if (block) {block ();}}