Skip to content

Instantly share code, notes, and snippets.

@vestige
Forked from Watson1978/timer.rb
Created November 5, 2011 15:39
Show Gist options
  • Save vestige/1341676 to your computer and use it in GitHub Desktop.
Save vestige/1341676 to your computer and use it in GitHub Desktop.
MacRuby : Sample of NSTimer
# -*- coding: utf-8 -*-
framework "Cocoa"
class AppDelegate
def initialize
# NSTimer の初期化
@timer = NSTimer.scheduledTimerWithTimeInterval(1.0,
target:self,
selector:"output:",
userInfo:nil,
repeats:true)
@count = 0
end
# NSTimer で定期的に呼び出されるメソッド
def output(timer)
puts @count
@count += 1
end
end
app = NSApplication.sharedApplication
app.delegate = AppDelegate.new
app.run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment