JX_GCDTimerManager is a NSTimer like tool implemented using GCD.
- Add the source files
JX_GCDTimerManager.h
andJX_GCDTimerManager.m
to your Xcode project. - Import
JX_GCDTimerManager.h
. - Use in you code.
__weak typeof(self) weakSelf = self;
[[JX_GCDTimerManager sharedInstance] scheduledDispatchTimerWithName:@"myTime_hash"
timeInterval:2.0
queue:dispatch_get_main_queue()
repeats:NO
fireInstantly:NO
action:^{
[weakSelf doSomething];
}];
You can add or remove functions as you need.
This component requires iOS 8.0+
.
If you are using JX_GCDTimerManager
as a singleton, you should watch out that timer with the same name could interfere each other, as the name is the unique key of the timer. Make sure to use unique names for timer instances.
JX_GCDTimerManager is provided under the MIT license. See LICENSE file for details.