Skip to content

Instantly share code, notes, and snippets.

@fluxsaas
Created July 15, 2010 06:05
Show Gist options
  • Save fluxsaas/476567 to your computer and use it in GitHub Desktop.
Save fluxsaas/476567 to your computer and use it in GitHub Desktop.
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