Created
July 15, 2010 06:05
-
-
Save fluxsaas/476567 to your computer and use it in GitHub Desktop.
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
class Timer | |
attr_accessor :input | |
def startTimer(to_process) | |
@startTime = Time.now | |
interval = NSTimer.timerWithTimeInterval 0.1, | |
target: self, | |
selector: "update_timer:", | |
userInfo: nil, | |
repeats: true | |
NSRunLoop.currentRunLoop.addTimer(interval, forMode: NSDefaultRunLoopMode) | |
NSRunLoop.currentRunLoop.runUntilDate(NSDate.distantFuture) | |
end | |
def update_timer(timer) | |
elapsed = Time.now - @startTime | |
@input.setDateValue(NSDate.dateWithString(@elapsed.to_s)) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment