我正在使用for
循环,因为我正在使用else if
条件.在其中一个else if
我想继续for
循环一些延迟.是否可以使用continue语句NSTimer
?如果可能,我该如何使用continue语句NSTimer
.
for(int i = 0; i<[array count];i++){
else if (condition)
{
}
else if (condition)
{
}
else if (condition)
{
}
else if (condition)
{
// Here I want to continue the for loop with some delay
}
else if (conditions)
{
}
else
{
}
}
Run Code Online (Sandbox Code Playgroud)
请任何人帮助我
使用NSThread sleepUntilDate:
和NSDate dateWithTimeIntervalSinceNow:
延迟.
例:
for(int i=0; i<5; i++){
[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0]];
NSLog(@"Delaying");
}
Run Code Online (Sandbox Code Playgroud)
输出:
15:57:46.383 Delaying
15:57:47.386 Delaying
15:57:48.388 Delaying
15:57:49.389 Delaying
15:57:50.391 Delaying
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1974 次 |
最近记录: |