CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.

PGMTimer 0.1.3

PGMTimer 0.1.3

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Mar 2016
SPMSupports SPM

Maintained by Pablo GM.



PGMTimer 0.1.3

  • By
  • Pablo GM

PGMTimer

This is a simple class to provide a Swift Timer with the following features: start, stop, pause, resume.

Usage

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

Requirements

How to use

Init timer:

    timer = Timer(timerEnd: 10.0, timerWillStart: {

        print("Timer started.")

    }, timerDidFire: { [weak self] time in

        self?.timerLabel.text = time

    }, timerDidPause: {

        print("Timer paused")

    }, timerWillResume: {

        print("Timer resumed")

    }, timerDidStop: {

        print("Timer stopped")

    }, timerDidEnd: { [weak self] time in

        self?.timerLabel.text = time

    print("Timer End")
    })

Perform actions:

    @IBAction func startTimer(sender: UIButton) {

        if timer.state == .TimerStateUnkown || timer.state == .TimerStateStopped || timer.state == .TimerStateEnded {

            timer.start()
        }
        else {
            print("Can not start")
        }
    }

    @IBAction func pauseTimer(sender: UIButton) {

        if timer.state == .TimerStateRunning {

            timer.pause()
        }
        else {
            print("Can not pause")
        }
    }

    @IBAction func resumeTimer(sender: UIButton) {

        if timer.state == .TimerStatePaused {

            timer.resume()
        }
        else {
            print("Can not resume")
        }
    }

    @IBAction func stopTimer(sender: UIButton) {

        if timer.state == .TimerStateRunning {

            timer.stop()
        }
        else {
            print("Can not stop")
        }
    }

Support

Supports iOS8 and above. XCode 7.0 is required to build the latest code written in Swift 2.0

Author

Pablo GM, [email protected]

License

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