TestsTested | ✓ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Apr 2015 |
Maintained by Comyar Zaheri, Comyar Zaheri.
Chronos is a collection of useful Grand Central Dispatch utilities. If you have any specific requests or ideas for new utilities, don't hesitate to create a new issue.
Chronos is part of a larger library for iOS and OS X called Olympus, which is currently under active development.
Chronos is available through Cocoa Pods. Add the following to your Podfile:
pod 'Chronos'
If you see the following error message:
[!] Unable to find a specification for
Chronos
Due to a bug in libgit2, your local copy of the Cocoapods Specs repository may need to be removed and re-cloned. More information on why and how to do this is available on the Cocoapods blog.
#import <Chronos/Chronos.h>
/** Create and start a timer */
CHRDispatchTimer timer = [CHRDispatchTimer timerWithInterval:1.0
executionBlock:^(CHRDispatchTimer *__weak timer, NSUInteger invocation) {
NSLog(@"%@", @"Execute repeating task here");
}];
[timer start:YES]; // Fire timer immediately
/** Pausing the timer */
[timer pause];
/** Permanently canceling the timer */
[timer cancel];
#import <Chronos/Chronos.h>
/** Create and start a timer */
CHRVariableTimer *timer = [CHRVariableTimer timerWithIntervalProvider:^NSTimeInterval(CHRVariableTimer *__weak timer, NSUInteger nextInvocation) {
return 2 * count; // Return interval according to function
} executionBlock:^(__weak id<CHRRepeatingTimer> timer, NSUInteger invocation) {
NSLog(@"Execute repeating task here");
}];
[timer start:YES]; // Fire timer immediately
/** Pausing the timer */
[timer pause];
/** Permanently canceling the timer */
[timer cancel];
Chronos is available under the MIT License.