Skip to content

Instantly share code, notes, and snippets.

@Watson1978
Created November 4, 2011 15:03
Show Gist options
  • Save Watson1978/1339519 to your computer and use it in GitHub Desktop.
Save Watson1978/1339519 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