title: Draw text with center alignment in Cocoa View
body: <p>I am trying to draw a string with new lines (\n) in a cocoa NSView with center alignment. For example if my string is:</p>
  
  <pre><code>NSString * str = @"this is a long line \n and \n this is also a long line"; 
  </code></pre>
  
  <p>I would like this to appear somewhat as:</p>
  
  <pre><code>  this is a long line
           and
  this is also a long line
  </code></pre>
  
  <p>Here is my code inside NSView drawRect method:</p>
  
  <pre><code>NSMutableParagraphStyle * paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
  
  [paragraphStyle setAlignment:NSCenterTextAlignment];
  
  NSDictionary * attributes = [NSDictionary dictionaryWithObject:paragraphStyle forKey:NSParagraphStyleAttributeName];
  
  NSString * mystr = @"this is a long line \n and \n this is also a long line";
  
  [mystr drawAtPoint:NSMakePoint(20, 20) withAttributes:attributes];
  </code></pre>
  
  <p>It still draws the text with left alignment. What is wrong with this code?</p>