Timer

Timer

A simple wrapper for NSTimer in Swift that lets you create timers using Swifty syntax and closures.

95842a43 Swift 3 · by Aral Balkan

Timer

A simple wrapper for Foundation.Timer in Swift that lets you create timers using Swifty syntax and closures.

This is the master branch (Swift 2.2.1). Also available: Swift 2.3 and Swift 3 branches.

Installation

Carthage compatible

Run the ./install script to install the dependencies for the demo app.

To include the Swift 3 version in your own projects, please make sure you specify the swift-3 branch in your Cartfile:

git "git@source.ind.ie:project/timer.git" ~> 3.0

Getting started

Run the ./dev script and play with the iOS demo app.

Usage

let myTimer = (IndieTimer(tickInterval: 1.0))
{
    /* with */ timer in

    print("This got called after one second.")

    // Stopping the timer so it doesn’t repeat.
    // You can also call .start(repeats: false)
    // to achieve the same effect.
    _ = timer.stop()

}
myTimer.start()

Credits

Copyright © Aral Balkan. Released with ♥ by Ind.ie under the MIT License.