title: How to wait for animation -- completion block
body: <p>I'm working on an app where two views meet somewhere on the screen. When they meet, a collision detector fires off this method. It's supposed to identify the appropriate base and then send both views to it. It does exactly that, but it happens instantly instead of over a period of 4 seconds. What am I missing? RADIUS is defined above this code. Does it have anything to do with arrow not being a UIView? The spriteView class is a subclass of UIView.</p>
  
  <pre><code>-(void)sendToBase:(spriteView *)arrow
  {
     int teamNumber = arrow.teamNumber;
     // Find the location of the base.
     for (UIView *scaledView in self.view.subviews) {
        if (scaledView.tag == 100) {
           for (UIView *base in scaledView.subviews) {
              if (base.tag &gt;= 1000) {
                 if (teamNumber + 1000 == base.tag) {
                    // We found the right base.
                    CGPoint newCenter;
                    newCenter.x = base.center.x + arc4random() % (int) floor(RADIUS) - RADIUS/2.0;
                    newCenter.y = base.center.y + arc4random() % (int) floor(RADIUS) - RADIUS/2.0;
                    [UIView animateWithDuration:4.0 delay:0.0 options:UIViewAnimationCurveLinear animations:^{
                       [arrow setCenter:newCenter];
                    } completion:^(BOOL finished) {
                       // After walking back to base, remove and create new objects
                       [arrow removeFromSuperview];
                       [self addArrow:scaledView toTeam:teamNumber];
                    }];
                 }
              }
           }
        }
     }
  }
  </code></pre>
  
  <p>On the off-chance that the class type mismatch was the problem, I modified the code thusly, with the same results.</p>
  
  <pre><code>-(void)sendToBase:(spriteView *)arrow
  {
     UIView *uiSpriteView = (UIView *)arrow;
     int teamNumber = arrow.teamNumber;
     // Find the location of the base.
     for (UIView *scaledView in self.view.subviews) {
        if (scaledView.tag == 100) {
           for (UIView *base in scaledView.subviews) {
              if (base.tag &gt;= 1000) {
                 if (teamNumber + 1000 == base.tag) {
                    // We found the right base.
                    CGPoint newCenter;
                    newCenter.x = base.center.x + arc4random() % (int) floor(RADIUS) - RADIUS/2.0;
                    newCenter.y = base.center.y + arc4random() % (int) floor(RADIUS) - RADIUS/2.0;
                    [UIView animateWithDuration:4.0 delay:0.0 options:UIViewAnimationCurveLinear animations:^{
                       [uiSpriteView setCenter:newCenter];
                    } completion:^(BOOL finished) {
                       // After walking back to base, remove and create new objects
                       [arrow removeFromSuperview];
                       [self addArrow:scaledView toTeam:teamNumber];
                    }];
                 }
              }
           }
        }
     }
  }
  </code></pre>