XWTimer
A Simple GCD Timer with Objective-C.
CocoaPod
pod 'XWTimer'
How to use?
target-selector
self.timer = [XWTimer timerWithTimeInterval:1.0 target:self selector:@selector(timerMethod) repeats:YES];
- (void)timerMethod
{
/// do somethings
}
block
__weak typeof(self) weakSelf = self;
self.timer =[XWTimer timerWithTimeInterval:1.0 repeats:YES block:^(XWTimer * _Nonnull timer) {
__strong typeof(weakSelf) strongSelf = weakSelf;
/// do somethings
}];
Start
[self.timer fire];
Pause
[self.timer pause];
Invalidate
[self.timer invalidate];