title: How to draw smooth path with NSBezierPath
body: <p>I am draing path with NSBezierPath currently:</p>
  
  <pre><code>- (void)drawRect:(NSRect)dirtyRect 
  {
      [[NSColor blueColor] set];
      [path stroke];
  }
  </code></pre>
  
  <p>But the line seems pretty ugly(not smooth)</p>
  
  <p>Then I googled for some solutions and I got this:</p>
  
  <pre><code>- (void)drawRect:(NSRect)dirtyRect 
  {
      NSGraphicsContext *graphicsContext;
      BOOL oldShouldAntialias;
  
      graphicsContext = [NSGraphicsContext currentContext];
      oldShouldAntialias = [graphicsContext shouldAntialias];
      [graphicsContext setShouldAntialias:NO];
  
      [[NSColor blueColor] set];
      [path stroke];
  
      [graphicsContext setShouldAntialias:oldShouldAntialias];
  }
  </code></pre>
  
  <p>But for me, noting changed, I still got the ugly path.</p>
  
  <p>Any suggestion?</p>
  
  <p>Thanks for answer.</p>
  
  <p>Here's the details:</p>
  
  <ol>
  <li>Create a cocoa application (not document-based)</li>
  <li>Create a new class "StretchView"</li>
  </ol>
  
  <h3>StretchView.h</h3>
  
  <pre><code>#import &lt;Cocoa/Cocoa.h&gt;
  
  @interface StretchView : NSView {
  
      NSBezierPath *path;
  }
  
  -(void)myTimerAction:(NSTimer *) timer;
  
  @end
  </code></pre>
  
  <h3>StretchView.m</h3>
  
  <pre><code>#import "StretchView.h"
  
  @implementation StretchView
  
  - (id)initWithFrame:(NSRect)frame 
  {
      self = [super initWithFrame:frame];
      if (self) {
  
          path = [[NSBezierPath alloc] init]; 
          NSPoint p = CGPointMake(0, 0); 
          [path moveToPoint:p]; 
          myTimer = [NSTimer scheduledTimerWithTimeInterval:1.0
                                                     target:self
                                                   selector:@selector(myTimerAction:)
                                                   userInfo:nil
                                                    repeats:YES];
      }
      return self;
  }
  
  - (void)drawRect:(NSRect)dirtyRect 
  {
      NSLog(@"drawRect");
  
      [[NSColor blueColor] set];
      [path stroke];
  }
  
  -(void)myTimerAction:(NSTimer *) timer
  {  
      NSPoint p = CGPointMake(a, b); //a, b is random int val
      [path lineToPoint:p]; 
      [path moveToPoint:p]; 
      [path closePath];
  
      [self setNeedsDisplay:YES];
  } 
  
  -(void)dealloc
  {
      [path release]; 
      [super dealloc];
  }
  
  @end
  </code></pre>
  
  <p>3.Open the Interface builder and drag a "Scroll view" to the main window<br>
  4.Choose the "Scroll view" and set the class "StretchView" (in class identity window)</p>