Created
August 15, 2016 12:57
-
-
Save alexkafer/b7f1b4d4b4b48cd4310e3f65c652f409 to your computer and use it in GitHub Desktop.
A simple swift timer program that runs in Xcode Playground
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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