GCDTimer is use replace NSTimer, so it can ellipsis invalited Timer, and use simple. Support merge previous task of the same timer, or abandoned previous task of the same timer. Efficiency than NSTimer.
CocoaPods is the recommended way to add KG_GCDTimer to your project.
- Add a pod entry for KG_GCDTimer to your Podfile
pod 'KG_GCDTimer'
- Install the pod(s) by running
pod install
. - Include KG_GCDTimer wherever you need it with
#import "KG_GCDTimer.h"
.
Alternatively you can directly add the KG_GCDTimer.h
and KG_GCDTimer.m
source files to your project.
- Download the latest code version or add the repository as a git submodule to your git-tracked project.
- Open your project in Xcode, then drag and drop
KG_GCDTimer.h
andKG_GCDTimer.h.m
onto your project. Make sure to select Copy items when asked if you extracted the code archive outside of your project. - Include KG_GCDTimer wherever you need it with
#import "KG_GCDTimer.h"
.
[[KG_GCDTimer sharedInstance] scheduledDispatchTimerWithName:@"timerName"
timeInterval:3.0f
queue:nil /* dispatch_get_global_queue */
repeats:YES
actionOption:KG_AbandonPreviousAction /* KG_MergePreviousAction */
action:^{
// do somthing
}];
[[KG_GCDTimer sharedInstance] cancelTimerWithName:@"timerName"];
This code is distributed under the terms and conditions of the MIT license.
A brief summary of each KG_GCDTimer release can be found in the CHANGELOG.