Skip to content

Instantly share code, notes, and snippets.

@alexkafer
Created August 15, 2016 12:57
Show Gist options
  • Save alexkafer/b7f1b4d4b4b48cd4310e3f65c652f409 to your computer and use it in GitHub Desktop.
Save alexkafer/b7f1b4d4b4b48cd4310e3f65c652f409 to your computer and use it in GitHub Desktop.
A simple swift timer program that runs in Xcode Playground
import UIKit
class MyClass {
func startTimer() {
NSTimer.scheduledTimerWithTimeInterval(2, target: self, selector: #selector(MyClass.onTimer(_:)), userInfo: nil, repeats: false)
}
@objc func onTimer(timer:NSTimer!) {
print("Timer here")
}
}
var anInstance = MyClass()
anInstance.startTimer()
CFRunLoopRun()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment