用于等待任何异步测试并在超过时间限制时您在测试中获得 STFail() 的 C 宏。WAIT_WHILE(whileTrue, limitInSeconds);
WAIT_WHILE(whileTrue, limitInSeconds)
WAIT_WHILE_WITH_DESC(whileTrue, seconds, description, ...)
WAIT_WHILE_EQUALS(value1, value2, limitInSeconds)
WAIT_WHILE_EQUALS_WITH_DESC(value1, value2, limitInSeconds, description, ...)
WAIT_WHILE_EQUALS_WITH_ACCURACY(value1, value2, accuracy, limitInSeconds)
WAIT_WHILE_EQUALS_WITH_ACCURACY_WITH_DESC(value1, value2, accuracy, limitInSeconds, description, ...)
WAIT_WHILE_NOT_EQUALS(value, equalTo, limitInSeconds)
WAIT_WHILE_NOT_EQUALS_WITH_DESC(value1, value2, limitInSeconds, description, ...)
AG_STALL_RUNLOPP_WHILE(whileTrue, limitInSeconds)
最基本的
__block BOOL jobDone = NO;
[CEO asyncFireAllEmployes:^{
jobDone = YES;
}];
WAIT_WHILE(!jobDone, 0.2); // stalls runloop until jobDone is true
WAIT_WHILE
将在给定时间段内使当前运行循环挂起。可以在主线程等中进行工作.. 像在这个愚蠢的例子中:
__block BOOL jobDone = NO;
[CEO asyncFireAllEmployes:^{
dispatch_async(dispatch_get_main_queue(), ^{
int value = 2 + 2;
[you tellWife2Plus2Is:4];
[CEO tellJanitorToStopBuggingYouAsync:^{
jobDone = YES;
}];
});
}];
WAIT_WHILE(!jobDone, 0.2);
尚未添加。