我有一个方法 -(void)showLyrics{} 我想从另一个方法调用它,但在一段时间后,每次连续调用之间的时间调用是不同的。 我就是这样做的
[self performSelector:@selector(showLyrics) withObject:nil afterDelay:2];
[self performSelector:@selector(showLyrics) withObject:nil afterDelay:5];
[self performSelector:@selector(showLyrics) withObject:nil afterDelay:10];
[self performSelector:@selector(showLyrics) withObject:nil afterDelay:12];
有人知道更好的方法吗?
最佳答案
调用一次
-(void)viewDidLoad {
[self performSelector:@selector(showLyrics) withObject:nil afterDelay:2];
}
做你的事 然后安排下一次
-(void)showLyrics {
int d=2;
//do your thing
d+=3;//or whatever
[self performSelector:@selector(showLyrics) withObject:nil afterDelay:d];
}
关于iphone - 我想以不同的时间间隔多次调用一个方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13172584/