0
[UIView animateWithDuration:1 animations:^{
    self.animateView.frame = CGRectMake(100, 100, 50, 50);
} completion:^(BOOL finished) {
    if (finished) {
        NSLog(@"animation finished");
    }
}];
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1]];
NSLog(@"after runUntilDate");

So many code like above,that's why? What will happen if I comment the runUntilDate line?

update: If I add next line(NSLog) to the last,it will not execute until animation finished. Looks like runUntilDate blocks main thread, so why we need to block thread here?

Sugite
  • 41
  • 4

1 Answers1

0

In you case, I think, nothing. See here

Srj0x0
  • 458
  • 3
  • 12
  • Why runUntilDate can block main thread?And when we need block main thread like here? – Sugite May 15 '17 at 13:44
  • Because runloop work in main thread. Ideally, you mustn't block main thread in any case. – Srj0x0 May 15 '17 at 14:02
  • runUntilDate just restart runloop's another iteration, why lead to thread blocking, can you explain at the source level?Thank you! – Sugite May 15 '17 at 14:43
  • In you case, main thread blocking, because animations always works in main thread – Srj0x0 May 15 '17 at 14:51