0

我有以下方法

-(void) showDie: (int) num;{
// do something
}

我想以 0.5 秒的时间间隔调用该方法。到目前为止,我有以下

SEL runShowDie;
[runShowDie performSelector:@selector(showDie:) withObject:rand];
[NSTimer scheduledTimerWithTimeInterval:.5 target:self selector:runShowDie userInfo:nil repeats:NO];

我究竟做错了什么?

4

2 回答 2

1

你把重复:没有在这一行使它成为YES

    [NSTimer scheduledTimerWithTimeInterval:.5 target:self selector:@selector(showDie:) userInfo:[NSString stringWithFormat:@"%d",rand] repeats:YES];
于 2013-08-23T09:54:24.023 回答
0

尝试

[self performSelector:@selector(showDie:) withObject: rand afterDelay:0.5f];

并删除NSTimer

于 2013-08-23T09:53:46.740 回答