performSelector在timeintervals中

时间:2013-08-23 09:51:19

标签: ios objective-c cocoa-touch

我有以下方法

-(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];

我做错了什么?

2 个答案:

答案 0 :(得分:1)

你把重复:在这一行中没有,使它成为是

    [NSTimer scheduledTimerWithTimeInterval:.5 target:self selector:@selector(showDie:) userInfo:[NSString stringWithFormat:@"%d",rand] repeats:YES];

答案 1 :(得分:0)

尝试

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

删除NSTimer