title: Is there a "right" way to have NSTextFieldCell draw vertically centered text?
body: <p>I have an <code>NSTableView</code> with several text columns. By default, the <code>dataCell</code> for these columns is an instance of Apple's <code>NSTextFieldCell</code> class, which does all kinds of wonderful things, but it draws text aligned with the top of the cell, and I want the text to be vertically centered in the cell.</p>
  
  <p>There is an internal flag in <code>NSTextFieldCell</code> that can be used to vertically center the text, and it works beautifully. However, since it is an internal flag, its use is not sanctioned by Apple and it could simply disappear without warning in a future release. I am currently using this internal flag because it is simple and effective. Apple has obviously spent some time implementing the feature, so I dislike the idea of re-implementing it.</p>
  
  <p>So; my question is this: <strong>What is the right way to implement something that behaves exactly like Apple's NStextFieldCell, but draws vertically centered text instead of top-aligned?</strong></p>
  
  <p>For the record, here is my current "solution":</p>
  
  <pre><code>@interface NSTextFieldCell (MyCategories)
  - (void)setVerticalCentering:(BOOL)centerVertical;
  @end
  
  @implementation NSTextFieldCell (MyCategories)
  - (void)setVerticalCentering:(BOOL)centerVertical
  {
      @try { _cFlags.vCentered = centerVertical ? 1 : 0; }
      @catch(...) { NSLog(@"*** unable to set vertical centering"); }
  }
  @end
  </code></pre>
  
  <p>Used as follows:</p>
  
  <pre><code>[[myTableColumn dataCell] setVerticalCentering:YES];
  </code></pre>