Skip to content

Instantly share code, notes, and snippets.

@nantekkotai
Created May 31, 2012 06:26
Show Gist options
  • Save nantekkotai/2841485 to your computer and use it in GitHub Desktop.
Save nantekkotai/2841485 to your computer and use it in GitHub Desktop.
Objective-Cでタイマーを使う

JavaScriptでいうところのsetTimeoutが使える。

// 30秒後にtimeoutメソッドを実行する
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:30.0f
                                                  target:self
                                                selector:@selector(timeout:)
                                                userInfo:nil
                                                 repeats:NO];

repeatsをYESにすると繰り返す(JSのsetIntervalになる)。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment