Grand Central Dispatch (GCD) Timer in Swift
import GCDTimer
class 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.
}
}
import GCDTimer
class Demo {
init() {
let timer = GCDTimer(intervalInSecs: 2)
timer.Event = {
timer.pause()
//Process after finishing the timer
}
timer.start()
}
}
- Add
github "hemantasapkota/GCDTimer"
to yourcartfile
- Execute
carthage update