title: How to use NSString drawInRect to center text?
body: <p>How can I draw a <code>NSString</code> centered within a <code>NSRect</code>?</p>
  
  <p>I've started off with: (an extract from the drawRect method of my custom view)</p>
  
  <pre><code>NSString* theString = ...
  [theString drawInRect:theRect withAttributes:0];
  [theString release];
  </code></pre>
  
  <p>Now I'm assuming I need to set up some attributes. I've had a look through Apple's Cocoa documentation, but it's a bit overwhelming and can't find anything for how to add paragraph styles to the attributes.</p>
  
  <p>Also, I can only find <em>horizontal</em> alignment, what about <em>vertical</em> alignment?</p>