title: How do I get -[NSString sizeWithFont:forWidth:lineBreakMode:] to work?
body: <p>I updated my question "<a href="https://stackoverflow.com/questions/406212/sizing-a-uilabel-in-the-iphone-sdk-to-fit">Sizing a UILabel (in the iPhone SDK) to fit?</a>" with a description of my problem with a suggested solution, but didn't get an answer.  Perhaps I'll have better results by asking a new question...</p>
  
  <p>I set a breakpoint after the following code:</p>
  
  <pre><code>NSString *theText = @"When in the Course of human events, it becomes necessary for one people to dissolve the political bands which have connected them with another, and to assume among the powers of the earth, the separate and equal station to which the Laws of Nature and of Nature's God entitle them, a decent respect to the opinions of mankind requires that they should declare the causes which impel them to the separation.";
  CGSize theSize = [theText sizeWithFont:[UIFont systemFontOfSize:17.0f] forWidth:260.0 lineBreakMode:UILineBreakModeWordWrap];
  </code></pre>
  
  <p><code>theSize.height</code> is 21 and <code>theSize.width</code> is 231. What am I doing wrong? That height can't be in pixels nor in number of lines.</p>
  
  <p>Note that <code>[UIFont systemFontOfSize:17.0f]</code> is meant to specify the default font.</p>
  
  <p><strong>Update</strong>: I changed the code to:</p>
  
  <pre><code>CGSize constraintSize;
  constraintSize.width = 260.0f;
  constraintSize.height = MAXFLOAT;
  NSString *theText = @"When in the Course of human events, it becomes necessary for one people to dissolve the political bands which have connected them with another, and to assume among the powers of the earth, the separate and equal station to which the Laws of Nature and of Nature's God entitle them, a decent respect to the opinions of mankind requires that they should declare the causes which impel them to the separation.";
  CGSize theSize = [theText sizeWithFont:[UIFont systemFontOfSize:17.0f] constrainedToSize:constraintSize lineBreakMode:UILineBreakModeWordWrap];
  </code></pre>
  
  <p><code>theSize.height</code> is 273.  That seems more like it.</p>