Latest 0.9.0
Homepage https://github.com/seanmcneil/Thrimer
License MIT
Platforms ios 10.0
Authors

CI Status
Version
License
Platform
CocoaPods

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • iOS 10.0+
  • Xcode 8.2+
  • Swift 3.0+

Installation

Thrimer is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "Thrimer"

Instructions

Basic setup

Import the framework:

import Thrimer

It is recommended that you set an instance variable for Thrimer:

class ViewController: UIViewController {
var thrimer: Thrimer?

Standard timer

Initialize your property, the following creates a non-repeating timer that runs for 10 seconds.

thrimer = Thrimer(interval: 10.0, repeats: false)

Next, set the delegate:

thrimer?.delegate = self

And start the timer:

thrimer?.start()

Delegate

To receive updates when the timer completes, you must comform to the ThrimerDelegate:

extension ViewController: ThrimerDelegate {
    func thrimerEvent(thrimer: Thrimer) {
        // Event triggered
    }
}

Pause timer

This creates a non-repeating timer with a 10 second duration.

let thrimer = Thrimer(interval: 10.0, repeats: false)
thrimer.delegate = self
thrimer.start()

Once the timer is running, you can now pause it:

thrimer.pause()

You can check to see if it is paused:

if thrimer.isPaused  {
    print("Timer is paused")
}

You can check to see how much time is remaining on the timer:

print(thrimer.timeRemaining ?? "Timer is not paused")

Finally, you can resume it:

thrimer.resume()

Changelog

Changelog | See the changes introduced in each version.

Author

seanmcneil, [email protected]

License

Thrimer is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "Thrimer",
    "version": "0.9.0",
    "summary": "A thread safe timer that can be paused",
    "description": "Thrimer is a thread-safe timer. It also has the ability to be paused & resumed as needed, for events such as backgrounding the app or a user pausing the game. The example app includes sample functions highlighting all of these features. Additionally, included unit tests also highlight how these work.",
    "homepage": "https://github.com/seanmcneil/Thrimer",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "seanmcneil": "[email protected]"
    },
    "source": {
        "git": "https://github.com/seanmcneil/Thrimer.git",
        "tag": "0.9.0"
    },
    "platforms": {
        "ios": "10.0"
    },
    "source_files": "Thrimer/Classes/**/*",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This