Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hemantasapkota/GCDTimer
Well-tested GCD Timer in Swift
https://github.com/hemantasapkota/GCDTimer
dispatch gcd swift timer
Last synced: 3 months ago
JSON representation
Well-tested GCD Timer in Swift
- Host: GitHub
- URL: https://github.com/hemantasapkota/GCDTimer
- Owner: hemantasapkota
- License: mit
- Created: 2015-06-04T05:26:00.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-01-13T00:59:31.000Z (almost 2 years ago)
- Last Synced: 2024-04-28T21:35:56.318Z (6 months ago)
- Topics: dispatch, gcd, swift, timer
- Language: Swift
- Homepage:
- Size: 102 KB
- Stars: 189
- Watchers: 10
- Forks: 22
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ios - GCDTimer - Well tested Grand Central Dispatch (GCD) Timer in Swift. (GCD / Getting Started)
- awesome-swift - GCDTimer - A well-tested GCD timer. (Libs / Thread)
- awesome-swift - GCDTimer - A well-tested GCD timer. (Libs / Thread)
- awesome-ios-star - GCDTimer - Well tested Grand Central Dispatch (GCD) Timer in Swift. (GCD / Getting Started)
- fucking-awesome-swift - GCDTimer - A well-tested GCD timer. (Libs / Thread)
- awesome-swift - GCDTimer - Well-tested GCD Timer in Swift ` 📝 4 years ago ` (Thread [🔝](#readme))
README
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
### GCDTimer ###
Well tested Grand Central Dispatch (GCD) Timer in Swift. Checkout the [test](GCDTimerTests/GCDTimerTests.swift) file.### Usage ###
#### Long running timer ####
```swift
import GCDTimerclass Demo {
init() {
let timer = GCDTimer(intervalInSecs: 20)
timer.Event = {
println("Hello World")
// Send some data to the server
}
timer.start()
//Don't forget to pause the timer in the AppDelegate:applicationWillResignActive(application: UIApplication) method.
}}
```
#### Autofinishing timer ####
```swift
import GCDTimerclass Demo {
init() {
let timer = GCDTimer(intervalInSecs: 2)
timer.Event = {
timer.pause()
//Process after finishing the timer
}
timer.start()
}
}
```#### Dispatch After - Delay ####
```swift
var index = 0
GCDTimer.delay(2) {
index += 1
}
```### Installation ###
* Add ```github "hemantasapkota/GCDTimer"``` to your ```cartfile```
* Execute ```carthage update```### Example ###
The example shows how to use GCDTimer to periodically poll newly submitted items from Hacker News.![ExampleSS](Example/GCDTimerExample/ExampleSS.png)
### License ###
The MIT License (MIT)Copyright (c) 2023 Hemanta Sapkota
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.