Skip to content

schun93/Chronos-Swift

 
 

Repository files navigation

Overview

Build Status Version Carthage compatible Platform License

Notice: The Travis-CI build is currently failing due to compatibility issues with Swift 1.2/Xcode 6.3.
              Related Issue: Travis-CI#3216

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.

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

Chronos is available through Cocoa Pods. Add the following to your Podfile:

pod 'Chronos-Swift'

Chronos is available through Carthage. Add the following to your Cartfile:

github "Olympus-Library/Chronos-Swift" "master"
Note:

If you see the following error message:

[!] Unable to find a specification for Chronos-Swift

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.

Using a Dispatch Timer

import Chronos

var timer = DispatchTimer(interval: 0.25, closure: {
            (timer: RepeatingTimer, count: Int) in
                println("Execute repeating task here")
            })

/** Starting the timer */
timer.start(true) // Fires timer immediately

/** Pausing the timer */
timer.pause()

/** Permanently canceling the timer */
timer.cancel()

Using a Variable Timer

import Chronos

var variableTimer: VariableTimer = VariableTimer(closure: { 
            (timer: RepeatingTimer, count: Int) -> Void in
                println("Execute repeating task here")
        }) {(timer: VariableTimer, count: Int) -> Double in
                return Double(2 * count) // Return interval according to function
        }

/** Starting the timer */
timer.start(true) // Fires timer immediately

/** Pausing the timer */
timer.pause()

/** Permanently canceling the timer */
timer.cancel()

Requirements

  • iOS 8.0 or higher
  • OS X 10.10 or higher

License

Chronos is available under the MIT License.

Contributors

About

Grand Central Dispatch Utilities

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 94.3%
  • Objective-C 4.0%
  • Ruby 1.7%