An open API service indexing awesome lists of open source software.

https://github.com/simplisticated/eternal

The way to manage time in Swift.
https://github.com/simplisticated/eternal

Last synced: 11 months ago
JSON representation

The way to manage time in Swift.

Awesome Lists containing this project

README

          


Eternal






# At a Glance

The way to manage time in Swift.

## How To Get Started

- Copy content of `Eternal` folder to your project.

or

- Use `Eternal` cocoapod

## Requirements

* iOS 9.0 and later
* Xcode 9.0 and later
* Swift 4

## Usage

```swift
/*
* Create timer.
*/
let timer1 = ETTimer()

/*
* Start timer with block.
* On every call of block you will get number of ticks
* and time interval which has gone from the start.
*/

timer1.startWithTimeInterval(1.0, repeats: true) { (timer, tickCount, timeIntervalSinceStart) -> Void in
NSLog("Timer did tick %d times. %.0f seconds has gone from the launch.", tickCount, timeIntervalSinceStart)
}

/*
* Example of timer which will tick one time only.
*/

timer1.startWithTimeInterval(1.0, repeats: false) { (timer, tickCount, timeIntervalSinceStart) -> Void in
NSLog("Timer did tick")
}

/*
* When you don't need timer to continue ticks,
* call stop() method:
*/

timer1.stop()

/*
* There's also a shortened form of timer creation:
*/

ETTimer.every(1.0) { (timer, tickCount, timeIntervalSinceStart) -> Void in
// Do something every second
}

/*
* Similar method for timer that will perform one time only:
*/

ETTimer.after(1.0) { (timer, tickCount, timeIntervalSinceStart) -> Void in
// Do something one time
}

```

## License

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