title: Making a ball/circle move in cocoa using nsbezierpath(objective -c))?
body: <p>I am trying to Create a point on an image when the application runs and then try to move the point slowly to a different location.
  here is my code.This code works but there are two problems.</p>
  
  <p>First, The processing has already happened before the window loads so I see only the finished result.(I want to show one point moving to another point in the image)</p>
  
  <p>Second,The previous point is not removed when I create a new point.So it doesn't look like the point is moving rather it looks like it is being duplicated.How do I remove a point.</p>
  
  <pre><code>- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
  {
      // Insert code here to initialize your application
      NSGraphicsContext* gc = [NSGraphicsContext currentContext];
  
      // Save the current graphics context settings
      [gc saveGraphicsState];
  
      // Set the color in the current graphics context for future draw operations
      [[NSColor blackColor] setStroke];
      [[NSColor redColor] setFill];
  
  
      for(int i=1;i&lt;100;i++){
  
          NSRect rect = NSMakeRect(130+i, 130, 10, 10);
          NSBezierPath* circlePath = [NSBezierPath bezierPath];
          [circlePath appendBezierPathWithOvalInRect: rect];
  
          // Outline and fill the path
          [circlePath stroke];
          [circlePath fill];
  
  
          //    // Restore the context to what it was before we messed with it
          //    [gc restoreGraphicsState];
      }
  }
  </code></pre>