高精度タイマーの使い方

NSTimer* timer;

- (void) gameTimer
{
  timer = [NSTimer 
  scheduledTimerWithTimeInterval:0.1
  target: self 
  selector:@selector(updateGameTimer:) 
  userInfo:nil 
  repeats:YES];
}

- (void) updateGameTimer:(CFRunLoopTimerRef *)timer
{
    NSLog(@"0.1秒おきに実行されます");
}

- (void) startGameTimer
{
    [self GameTimer]; // timerをスタート
}

- (void) stopGameTimer
{
   [timer invalidate]; // timerをストップ
}


ただし、ソフトウェアタイマーなので処理速度が変わる時がある!!!<ーーー駄目じゃん
なのでNSDateの方がいいと思う。
最終更新:2010年06月20日 22:45
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。