https://github.com/comyar/chronos
:hourglass: Grand Central Dispatch Utilities
https://github.com/comyar/chronos
Last synced: 8 months ago
JSON representation
:hourglass: Grand Central Dispatch Utilities
- Host: GitHub
- URL: https://github.com/comyar/chronos
- Owner: comyar
- License: mit
- Archived: true
- Created: 2015-03-31T03:39:57.000Z (about 11 years ago)
- Default Branch: main
- Last Pushed: 2024-08-06T00:43:30.000Z (almost 2 years ago)
- Last Synced: 2024-08-06T02:51:36.219Z (almost 2 years ago)
- Language: Objective-C
- Homepage:
- Size: 104 KB
- Stars: 15
- Watchers: 6
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## DEPRECATED IN FAVOR OF [Chronos-Swift](https://github.com/comyarzaheri/Chronos-Swift)

# Overview
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.
## Utilities
* **DispatchTimer** - A repeating timer that fires according to a static interval, e.g. "Fire every 5 seconds".
* **VariableTimer** - A repeating timer that allows you to vary the interval between firings, e.g. "Fire according to the function `interval = 2 * count`."
# Usage
### Quick Start
##### CocoaPods
Add the following to your Podfile:
```ruby
pod 'Chronos'
```
##### Carthage
Add the following to your Cartfile:
```ruby
github "comyarzaheri/Chronos" "master"
```
### Using a Dispatch Timer
```objective-c
#import
/** 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];
```
### Using a Variable Timer
```objective-c
#import
/** 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 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];
```
# Requirements
* iOS 7.0 or higher
* OS X 10.9 or higher
# License
Chronos is available under the [MIT License](LICENSE).
# Contributors
* [@comyar](https://github.com/comyar)
* [@schun93](https://github.com/schun93)