I need to schedule a Timer for firing a function every second but I see that in Xcode 8 beta 3 the scheduledTimer is only available for iOS 10.
Is there any alternat
Swift 3
func runCode(in timeInterval:TimeInterval, _ code:@escaping ()->(Void))
{
DispatchQueue.main.asyncAfter(
deadline: .now() + timeInterval,
execute: code)
}
func runCode(at date:Date, _ code:@escaping ()->(Void))
{
let timeInterval = date.timeIntervalSinceNow
runCode(in: timeInterval, code)
}
func test()
{
runCode(at: Date(timeIntervalSinceNow:2))
{
print("Hello")
}
runCode(in: 3.0)
{
print("World)")
}
}