The Problem
If you have ever worked with animations in iOS using UIKit you have most likely ended up with nested animation blocks and intractable code at some point. One of the problems that comes up is trying to chain multiple animations. You want animation B to run only after animation A has completed, and maybe then do something when animation B completes. This would look something like
[UIView animateWithDuration:0.25 animations:^() {
// animation A
} completion:^(BOOL finished) {
if (finished) {
[UIView animateWithDuration:0.25 animations:^() {
// animation B
} completion:^(BOOL finished) {
// Other code
}];
}
}];
And then you may want animations C and D to run after that, so much for clean code.
Another problem with this approach is that you can't easily switch or manipulate the animations. For instance you may want to run animation B after animation A in some cases and animation C after animation A in some other cases. Or you may want to dynamically change the properties of the animation like the duration.