我在我的应用程序中使用 NSRunLoop。只有一个说法
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:2]];
在 for 循环中执行。需要每两秒更新一次某些文本,持续三次。一切正常,但是当我退出它运行的屏幕(并且在它运行时这是最重要的)然后再次进入屏幕然后再次退出时,我的应用程序崩溃了。我想如果我在运行时退出,我必须停止运行 NSRunLoop,但我不知道该怎么做。你能给我一些建议吗?
这是我的循环:
for (int i = 1;i <= 3;i++)
{
int result = [self analyzeCards];
((UILabel *)[bidLabels objectAtIndex:i]).text = [bidResults objectAtIndex:result];
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:2]];
bidIndexes [i - 1] = result;
}