A swift wrapper for NSTimer
Switch branches/tags
Nothing to show
Clone or download
samhann Merge pull request #9 from Binur/master
made the TimerManageable protocol's extension's methods public
Latest commit dc84a5f May 12, 2016
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Every.xcodeproj Add tests Jan 8, 2016
Every Add tests Jan 8, 2016
EveryTests Added unit tests for clear timer methods. Jan 21, 2016
Example Added TimerManageableProtocol Jan 8, 2016
src made the protocol's extension's methods public May 12, 2016
.gitignore Initial commit Jan 5, 2016
Every.swift.podspec Add podspec Jan 20, 2016
LICENSE Initial commit Jan 5, 2016
README.md Update README on pod support Jan 20, 2016

README.md

Every.Swift - A Convenient NSTimer Wrapper

Usage

Provided that your class implement TimerManageable protocol you just do:

self.every(3.seconds) {
    print("hello")
    return true
}

Prints "hello" every 3 seconds.

Return true from the closure to continue , false to invalidate the timer.

Alternatively , you can use the following method to invalidate all timers of the receiver: self.clearTimers()

Normally you're are responsible of invalidating the timers you created. If the timer is not invalidated before the object it's been tied to it will be invalidated next time the timer is elapsed and before calling the ElapsedHandler.

TODO :

  • Investigate automatic invalidation of timer if owner is Swift object.
  • Add a project and test target.
  • Improve unit test coverage.
  • Support milliseconds.
  • Embed in a framework.
  • More representative example application.
  • OS X support.
  • Carthage support.
  • CocoaPod support.