4
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【コピペ用】インターバル処理 (Objective-C/Swift)

Last updated at Posted at 2015-08-22

コピペ用メモ

Swift


var tm: NSTimer!

...

tm = NSTimer.scheduledTimerWithTimeInterval(
    1,
    target: self,
    selector: Selector("hoge"),
    userInfo: nil,
    repeats: true)

...

func hoge(timer: NSTimer) {
  // TODO
}
timer.invalidate() // 停止

Objective-C


NSTimer *tm;

...

tm = [NSTimer
  scheduledTimerWithTimeInterval:1.5f
  target:self
  selector:@selector(hoge:)
  userInfo:nil
  repeats:YES
];

...

-(void)hoge: (NSTimer*)timer{
    // TODO
}

...
[tm invalidate] // 停止
4
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?