title: EXC_BAD_ACCESS on UITextAttributeFont (Invalid iOS version)
body: <p>I'm using setTitleTextAttributes to change the font on a <code>UISegmentedControl</code> as follows.</p>
  
  <pre><code>UIFont *font = [UIFont boldSystemFontOfSize:14.0f];
  NSDictionary *attributes = [NSDictionary dictionaryWithObject:font forKey:UITextAttributeFont];
  [self setTitleTextAttributes:attributes forState:UIControlStateNormal];&lt;/pre&gt;&lt;/code&gt;
  </code></pre>
  
  <p>This works fine in the simulator, but crashed when running on an iPad.  The bad access fault occurs on creation of the dictionary and I used an NSLog statement to verify that UITextAttributeFont is generating the fault.</p>
  
  <p>Any ideas what the problem is here or if there is an alternative method to set the font?</p>
  
  <p><strong>EDITED</strong></p>
  
  <p>I just realized the iPad is running iOS 4 (I believe this is supported on iOS >= 5).  What is the best way to test for version support?</p>
  
  <p>Based on Dirty Henry's suggestion, the correct implementation is as follows.</p>
  
  <p><pre><code>if ([self respondsToSelector:@selector(setTitleTextAttributes: forState:)]) {
        UIFont *font = [UIFont boldSystemFontOfSize:14.0f];
        NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys: font, UITextAttributeFont, nil];
        [self setTitleTextAttributes:attributes forState:UIControlStateNormal];
  }</pre></code></p>