The documentation is clear on the fact that animations (invoked with [UIView commitAnimations]) execute on a separate thread. What's not clear (to me, anyway) is whether the animationDidStopSelector is executed on the main (UI) thread or the same thread as the animation.
Given the following code:
- (void) doSomethingCool {
// Fade out someView
[UIView beginAnimations:@"myAnimation" context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDone:finished:context:)];
someView.alpha = 0.0;
[UIView commitAnimations];
}
- (void) animationDone:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
if( [animationID isEqual:@"myAnimation"] ) {
[someView removeFromSuperview];
}
}
I've heard that accessing UI elements on a thread other than the main thread is "generally bad", so if the animationDone call happens on a different thread, then the above code would do bad things, yes?
It seems not to do bad things. But I have been chasing a seemingly random occasional crash which happens after this animation, and I'm wondering if there's some threading issue.