title: UITouch touchesMoved Finger Locations Animating a View via CAKeyframeAnimation
body: <p>I am re-writing my question because it is modified a lot and now it became a new question. </p>
  
  <pre><code>- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
  {
      UITouch *touch = [touches anyObject];
      location = [touch locationInView:self.view];
      CGPoint prevLocation = [touch previousLocationInView:self.view];
      CGFloat distanceFromPrevious = [self distanceBetweenPoints:location :prevLocation];
      NSTimeInterval timeSincePrevious = event.timestamp - self.previousTimestamp;
      if (locArray == NULL) {
          locArray = [[NSMutableArray alloc] init];
      }
      [locArray addObject:[NSValue valueWithCGPoint:prevLocation]];
      CGFloat speed = distanceFromPrevious/timeSincePrevious;
      self.previousTimestamp = event.timestamp;
  
      //NSLog(@"speed %f | time %f", speed, timeSincePrevious);
  
  }
  - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
  {
      CALayer *animLayer = ball.layer;
      animLayer.bounds = ball.bounds;
      animLayer.position = CGPointMake(self.view.frame.size.width/2, 0);
      CGMutablePathRef path = CGPathCreateMutable();
      CGPathMoveToPoint(path, NULL, self.view.frame.size.width/2, 380);
  
      for (int i=0; i&lt;[locArray count]; i++) {
          NSValue *val = [locArray objectAtIndex:i];
          CGPoint p = [val CGPointValue];
          CGPathAddLineToPoint(path, NULL, p.x, p.y);
  
          NSLog(@"Points %f %d", p.y, i);
      }
      CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"path"];
      animation.duration = 4.0f;
      animation.path = path;
      animation.removedOnCompletion = NO;
      CGPathRelease(path);
  
      [animLayer addAnimation:animation forKey:@"path"];
      locArray = nil;
  
  }
  </code></pre>
  
  <p>I am trying to a view class named ball based on UITOuch touchesMoved event captures. LocArray is holding CGPoint values of touches moved. 
  I tried to put these values into my CGMutablePathRef.
  And than, I tried to animate the ball on path created by user finger movement input.</p>
  
  <p>I cannot make my animation work. What is wrong with it?</p>
  
  <p>EDIT: </p>
  
  <p>I have changed :</p>
  
  <pre><code>CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
  </code></pre>
  
  <p>animationWithKeyPath value is now position and now it is working :) </p>
  
  <p>I have some slight problems but I have solved it. </p>
  
  <p>But my new question is:</p>
  
  <p>Ball view is returning back to its starting point after completing the animation and stops.</p>
  
  <p><strong>I want it to stay at its final point in path.</strong></p>
  
  <p>SOLUTION: I found the solution finally.</p>
  
  <p>I added a CGPoint finalPoint = [locArray count]-1 value.
  Then, </p>
  
  <pre><code>animLayer.position = finalPoint;
  </code></pre>
  
  <p>That solved it all. Now the ball stays at final position of finger touch captured by touchesMoved event.</p>